【问题标题】:Installing RVM (Ruby Version Manager)安装 RVM(Ruby 版本管理器)
【发布时间】:2011-03-15 15:49:17
【问题描述】:

谁能把它翻译成我需要采取的可管理的步骤:

~ 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的加载文件,我该如何编辑它?

【问题讨论】:

  • 当然。加入 irc.freenode.net 上的#rvm,我们就会这样做。

标签: ruby


【解决方案1】:

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

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

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

安装 rvm 后,

根据您使用的文本编辑器,我使用的是 mate,所以我输入了:

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

你应该看到 ruby​​1.9.1

要恢复默认设置,请键入:

rvm default

现在您应该获得 ruby​​ 1.8.6(或 1.8.7,取决于您的默认值)。

【讨论】:

  • 我们不应该获得稳定版本而不是头部分支吗? \curl -sSL https://get.rvm.io | bash -s stable --ruby - 另外,如果它在您的 .bashrc 中,为什么 .bash_profile 需要更新?
【解决方案2】:

我在RVM website 的同一步骤中遇到了问题:

第一次安装 RVM 时,在所有路径加载等之后,必须将以下行放入配置文件的最后: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source " $HOME/.rvm/scripts/rvm"

在 OS X 上我的用户主目录中的 .profile 文件、.bash_profile 和 .bashrc 文件中插入该行后,终于让它工作了。

似乎所有这些都不是必需的。由于 RVM 网站只说“将以下行放入您的个人资料中”,因此对于像我这样并不真正知道我的个人资料是什么的菜鸟来说,这是一种误导。

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

【讨论】:

  • 我刚刚对此进行了测试,如果我只在我的 .profile 文件中包含这一行,RVM 就可以为我工作。仅供参考。
  • 好吧,我终于想通了。该行代码只需要在 .bash_profile 文件中。奇怪的是,您需要在对这些文件的任何更改生效之前打开一个新的终端窗口,所以这导致我在确定哪些文件是需要这行代码的文件并获得“rvm”时出现问题是一个函数”响应,您需要验证是否正确安装了 rvm 我怀疑(但我不确定)使用“重新加载 rvm”命令也可能有效。
  • 您可以使用“source .bash_profile”在打开的终端中重新加载配置文件。