简体   繁体   English

在Windows中通过Cygwin安装RVM时出错

[英]Error Installing RVM through Cygwin in Windows

I am attempting to install RVM through Cygwin, following this tutorial . 按照本教程 ,我尝试通过Cygwin安装RVM。

AFter creating the directory and cloning the git repository, I need to run ./osx_or_cygin_kick_off to begin the installation process. 创建目录并克隆git存储库后,我需要运行./osx_or_cygin_kick_off来开始安装过程。

This is the error message I am getting: 这是我收到的错误消息:

  $ ./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()

I read somewhere that converting the files to unix format via doc2unix might solve the problem, but it is only creating more error messages. 我读过某个地方的文章说,通过doc2unix将文件转换为unix格式可能会解决问题,但是这只会产生更多错误消息。

Any suggestions? 有什么建议么?

Edit: 编辑:

The problem is that some Cygwin git installations try to do magic linefeed handling. 问题是某些Cygwin git安装尝试执行魔术换行处理。 To fix git so it stops mangling line endings, run: 要修复git以使其停止破坏行尾,请运行:

git config --global core.autocrlf false

Original answer made more generic after comment clarification: 在澄清评论后,原始答案变得更通用:

The file contains CRLF ( \\r\\n ) end-line sequences, which is typical on Windows. 该文件包含CRLF( \\r\\n )结束行序列,这在Windows上是典型的。 Unix doesn't like it, though; 但是,Unix不喜欢它。 Unix (and Cygwin) want just LF ( \\n ). Unix(和Cygwin)只需要LF( \\n )。 I'm guessing you cut-and-pasted that file, or downloaded it through some mechanism that appended Windows line endings. 我猜您是剪切并粘贴了该文件,还是通过某种附加Windows行尾的机制下载了该文件。

To fix files in Cygwin: 要在Cygwin中修复文件:

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

Check and make sure filename.tmp looks ok, then: 检查并确保filename.tmp看起来正常,然后:

mv -f filename.tmp

Alternately, do a browser download and save (rather than cut and paste), or from the Cygwin shell, download using curl or wget . 或者,执行浏览器下载并保存(而不是剪切和粘贴),或者从Cygwin外壳中使用curlwget下载。

In all of the above cases, you probably won't have an executable file (just readable). 在上述所有情况下,您可能都没有可执行文件(可读)。 You can either make it executable with: 您可以通过以下方式使它可执行:

chmod 755 filename

Or run it through the shell explicitly: 或通过外壳显式运行它:

sh filename

You'll run into this problem often if you use Windows editors to manipulate your Cygwin files. 如果使用Windows编辑器来处理Cygwin文件,则经常会遇到此问题。 Editors inside Cygwin will be fine (eg Vim). Cygwin中的编辑器会很好(例如Vim)。 Optionally, many free Windows editors support Unix line endings. 可选地,许多免费的Windows编辑器都支持Unix行尾。 Notepad++ is a good one with a Unix line-ending option. Notepad ++是一个不错的选择,带有Unix行尾选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM