我在Mac OS X上遇到“RVM不是函数”错误,并且没有发布的解决方案

我在Mac OS x 10.8.2(“Mountain Lion”)上,我成功安装了RVM 1.17.8及其依赖项。 我可以使用它来安装使用rvm install 1.9.2 Ruby版本,但我无法在不收到此错误的情况下执行rvm use

 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 

我已经尝试运行source ~/.rvm/scripts/rvm ,它运行时没有返回错误,但当我尝试使用RVM在终端会话中设置Ruby版本时,我仍然得到“RVM不是函数”错误。

我还尝试使用rvm implode卸载并重新安装RVM。 我已经没有想法了,我似乎无法在网上找到更多解决方案。 救命?

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

 rvm get head --auto-dotfiles 

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

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

寻找.profile,如果存在,删除它! loof for .zshrc,如果存在,删除它! 现在,使用vi编辑.bash_profile,添加此行

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

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

对我来说工作正常!