16

我在 Mac OS x 10.8.2(“Mountain Lion”)上,并且成功安装了 RVM 1.17.8 及其依赖项。我可以使用它来安装 Ruby 版本,但是如果没有出现此错误rvm install 1.9.2,我将无法执行:rvm use <version>

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

我在 ~/.bash_profile 中有以下内容,我已将其设置为在source ~/.bash_profile启动终端窗口时使用 运行:

export SVN_EDITOR=vim
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[ -r ~/.bashrc ] && source ~/.bashrc

我试过 running source ~/.rvm/scripts/rvm,它运行时没有返回错误,但是当我尝试使用 RVM 在终端会话中设置 Ruby 版本时,我仍然收到“RVM is not a function”错误。

我还尝试使用rvm implode. 我的想法已经用完了,我似乎无法在网上找到更多解决方案。帮助?

4

3 回答 3

29

确保您的 shell 初始化文件设置正确:

rvm get head --auto-dotfiles

然后转到您的终端模拟器首选项并启用登录 shell,有时它需要使用/bin/bash --login。还要确保在更改设置后完全关闭终端并重新打开它。

于 2013-01-12T02:06:50.520 回答
17

该解决方案最终出现在 RVM帮助和支持页面上,位于“.bash_profile 未在 OSX 上加载”部分。似乎问题在于我将终端设置为使用“默认登录 shell”打开,当我将其更改为使用 Preferences/Setup 中的命令“/usr/bash”打开时,“source ~/.rvm/ scripts/rvm" 开始工作,并且 rvm 现在被识别为一个函数。

于 2013-01-12T16:33:35.717 回答
-3

寻找.profile,如果存在,删除它!.zshrc 的 loof,如果存在,请将其删除!现在,使用 vi 编辑您的 .bash_profile,添加这一行

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

现在,关闭所有控制台服务并再次打开,使用 $ rvm gemset use global

为我工作好!

于 2014-07-24T00:38:09.527 回答