在Windows 7上通过Vagrant运行Django时的CRLF问题

时间:2014-09-26 16:58:53

标签: django git bash virtual-machine vagrant

我正在使用Vagrant和Oracle Virtual Machine在Windows上运行Django项目。问题是,当我尝试执行其中一个文件时,我遇到了错误:

-bash: /url_to_my_file: /bin/bash^M: bad interpreter: No such file or directory

我已经用Google搜索了问题,这是尝试的内容:

1)在Git Bash:

git config --global core.autocrlf false
git config core.autocrlf false
git config --global core.eol lf
git config core.eol lf

2)在Vagrant SSH Git:

git config --global core.autocrlf input
git config core.autocrlf input
git config --global core.eol lf
git config core.eol lf

3)将.gitattributes添加到Git项目主文件夹:

* text eol=lf

4)使用dos2win转换Vagrant VM内的所有文件(绝对措施):

find . -type f \! -path \*/\.svn/\* -exec dos2unix {} \;

仍然没有结果......可能有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

我怀疑您的文件已经使用'CRLF`行结尾签入。

您可能需要normalize the line endings in your repository

(见https://stackoverflow.com/a/1511273/537554)。