错误在Windows中通过Cygwin安装RVM

我试图通过Cygwin安装RVM,按照本教程 。

在创build目录并克隆git仓库时,我需要运行./osx_or_cygin_kick_off来开始安装过程。

这是我得到的错误消息:

$ ./osx_or_cygwin_kick_off ./automation/rvm/rvm_install: line 2: $'\r': command not found ./automation/rvm/rvm_install: line 3: syntax error near unexpected token `$'\r'' '/automation/rvm/rvm_install: line 3: `install_rvm() ./automation/rvm/rvm_install_some_rubies: line 2: $'\r': command not found ./automation/rvm/rvm_install_some_rubies: line 3: syntax error near unexpected token `$'\r'' '/automation/rvm/rvm_install_some_rubies: line 3: `install_some_rubies() 

我读过的地方,通过doc2unix转换文件为Unix格式可能会解决这个问题,但它只是创造更多的错误信息。

有什么build议么?

编辑:

问题是一些Cygwin git安装尝试执行幻数换行处理。 要修正混帐,以便停止mangling行结束,请运行:

 git config --global core.autocrlf false 

评论澄清后,原始答案更为通用:

该文件包含CRLF( \r\n )结束行序列,这在Windows上是典型的。 Unix虽然不喜欢, Unix(和Cygwin)只需要LF( \n )。 我猜你是剪切粘贴该文件,或者通过一些附加Windows行结尾的机制下载它。

修复Cygwin中的文件:

 tr -d '\r' <filename >filename.tmp 

检查并确保filename.tmp看起来不错,然后:

 mv -f filename.tmp 

或者,浏览器下载并保存(而不是剪切和粘贴),或从Cygwin shell下载,使用curlwget下载。

在上述所有情况下,您可能不会有可执行文件(只读)。 您可以使其可执行:

 chmod 755 filename 

或者明确地通过shell运行它:

 sh filename 

如果您使用Windows编辑器来操作Cygwin文件,则会经常遇到此问题。 Cygwin里面的编辑会很好(比如Vim)。 可选地,许多免费的Windows编辑器都支持Unix行结尾。 记事本++是一个很好的与Unix行结束选项。