安装RVM(Ruby版本管理器)

有人可以将此翻译成我需要采取的可管理步骤:

~ Wayne You must now finish the install manually: 1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings: [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm Please note that this must only occur once - so, you only need to add it the first time you install rvm. 2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly). This means that if you see '[ -z ] && return' then you must change this line to: if [[ ! -z ]] ; then ... original content that was below the && return line ... fi # <= be sure to close the if. #EOF .bashrc Be absolutely *sure* to REMOVE the '&& return'. If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile. placing all non-interactive items in the .bashrc, including the 'source' line above 3) Then CLOSE THIS SHELL and open a new one in order to use rvm. [ -z "$PS1" ] && return WARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc. This means that if you see '[ -z $PS1 ] && return' then you must change this line to: if [[ -n $PS1 ]] ; then ... original content that was below the && return line ... fi # <= be sure to close the if. #EOF .bashrc Even if you use zsh you should still adjust the .bashrc as above. If you have any questions about this please visit #rvm on irc.freenode.net. Installation of RVM to /home/kapplej/.rvm/ is complete. 

我是一个完整的新手,所以我甚至不确定哪个是shell的加载文件,我该如何编辑它?

我发现了如何做到这一点,希望这能节省一些时间:

要安装RVM,请在终端中输入以下内容:

 bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) 

一旦你安装了rvm,

根据您使用的文本编辑器,我使用配偶,所以我输入:

 mate .bashrc 

然后打开文本编辑器窗口后,将此行复制并粘贴到其中:

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

现在保存并关闭该窗口。

然后重复:

 mate .bash_profile 

关闭该终端并重新启动新终端

输入:

 rvm use 1.9.1 (or 1.9.2) 

然后键入:

 ruby -v 

你应该看到ruby1.9.1

要恢复默认值,请输入:

 rvm default 

现在你应该得到ruby1.8.6(或1.8.7,具体取决于你的默认值)。

我在RVM网站上遇到了同样的问题:

第一次安装RVM时,必须在所有路径加载后将最后一行放入最终的配置文件中:[[-s“$ HOME / .rvm / scripts / rvm”]] && source“$ HOME / .rvm /脚本/ RVM”

最后,在将该行插入OS X上用户主目录中的.profile文件,.bash_profile和.bashrc文件后,它才能工作。

似乎所有这些都不是必需的。 由于RVM网站只说“在你的个人资料中添加以下内容”,这对我这样一个不知道我的个人资料的菜鸟有点误导。

有人可以告诉我哪些文件(配置文件,.bash_profile和.bashrc文件)我可以从中删除该行?

比…更好

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

使用:

 [[ -s "~/.rvm/scripts/rvm" ]] && source "~/.rvm/scripts/rvm" 

如果你使用$HOME ,当你运行sudo bash你得到一些丑陋的消息:

 WARNING: Could not source '/usr/local/rvm/scripts/base' as file does not exist. RVM will likely not work as expected. __rvm_ensure_is_a_function: command not found __rvm_setup: command not found cat: /usr/local/rvm/VERSION: No such file or directory __rvm_conditionally_add_bin_path: command not found rvm_is_a_shell_function: command not found __rvm_teardown: command not found