美文网首页
sqitch Cannot find deploy templa

sqitch Cannot find deploy templa

作者: 宝宝家的隔壁老王 | 来源:发表于2017-05-15 19:21 被阅读59次

    最近项目使用 sqitch 对数据库的表格式做变更的时候,报了如上错误

    报错详情如下:
    Use of uninitialized value $name in concatenation (.) or string at /usr/local/share/perl/5.18.2/App/Sqitch/Command/add.pm line 144.
    Use of uninitialized value $name in concatenation (.) or string at /usr/local/share/perl/5.18.2/App/Sqitch/Command/add.pm line 144.
    Use of uninitialized value $name in concatenation (.) or string at /usr/local/share/perl/5.18.2/App/Sqitch/Command/add.pm line 144.
    Cannot find deploy template
    
    • 因为之前在使用 sqitch 做 add 变更的时候,并没有出错,所以很奇怪,仔细检查之后也在发现当前路径下, deploy 目录是存在的,为什么会报上述错误呢?
    • google, Bing, 百度上搜了之后,终于找到了类似的问题,原地址如下:我是类似的问题
    • 如果你懒得点进去,一句话概括问题点:你的 sqitch.conf 文件出错了
    原因如下:

    sqitch.conf 文件在同事做版本合并的时候将其从 LF 格式变为了 CSRF 格式,我查了一下合并文件变更记录,确实是从 LF 变为了 CSLF。

    • Dos 和 Windows 环境使用回车换行 (CSLF) 也就是 \r\n 表示下一行;
    • Unix/Linux 采用换行 (LF) 也就是 \n 表示下一行;
    • Mac OS 也是采用换行 (LF) 表示下一行。

    所以在使用 github 时要进行如下配置,来进行不同环境下的文件自动转换:
    $git config --global core.autocrlf true

    • core.autocrf 是 git 中负责处理line endings的变量,可以设置三个值--true,input,false
    • true:

    If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit.。

    设置为 true,添加文件到 git 仓库(即提交代码)时,git 将其视为文本文件。他将把 CRLF 变成 LF。有人check的时候,会将LF 文件转换为 CRLF。Mac 和 Unix/Linux 尽量不要使用这个配置。
    - input:
    设置为input时,添加文件 git 仓库(即提交代码)时,git 把 CRLF 编成 LF。当有人Check代码(即从 git 仓库迁出代码)时,按照 input 的方式,即不做修改,完全照搬 git 仓库里的。因此在 window 操作系统下,尽量不要使用这个设置。
    - false:
    

    If core.autocrlf is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok。

    设置为false时,line-endings将不做转换操作。文本文件保持原来的样子。
    
    ###### 解决方法:
    - sqitch 在最开始使用的时候肯定是正常的,所以把之前用的正常的 sqitch.conf 文件,(Mac 或 Unix/Linux 下为 LF 文件,Windows 或 Dos 下 CRLF 文件)根据自己的环境选择文件类型将现在的 sqitch.conf 文件替换;
    - 在 git 中进行配置:
    windows 或 Dos下:
    `$git config --global core.autocrlf true`
    Mac 或 Unix/Linux 下:
    `$git config --global core.autocrlf input`
    - 这样就可以保证不同开发环境下 sqitch 可以正常工作,当然也可以将 sqitch.conf 文件添加到 `.gitignore` 文件。
    - 祝好运

    相关文章

      网友评论

          本文标题:sqitch Cannot find deploy templa

          本文链接:https://www.haomeiwen.com/subject/utnhxxtx.html