我刚安装了RVM,但是不能让它工作。我在我的.profile文件的末尾有这样的一行:

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

我试图运行源.profile和重新启动终端,但仍然,当我运行rvm使用1.9.2时,我得到:

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

我的系统是Ubuntu 11.10。


当前回答

我在一个新的rvm安装中也遇到了这个问题,这里的答案都没有解决它。进入官方rvm站点,在基础部分,他们有这样的命令:

# from http://rvm.io/rvm/basics rvm env——path (rvm 1.9.3)

您应该将1.9.3更改为您真正想要的ruby版本,并且它将使rvm成为一个函数,而不考虑shell类型。

其他回答

您需要运行以下命令

$ source ~/.rvm/scripts/rvm

然后运行这个

$ type rvm | head -n 1

如果你得到

rvm is a function

问题解决了。

您还需要运行user$ rvm requirements以查看操作系统的依赖项要求

来源:https://rvm.io/rvm/install/

我忘记提到你需要把这个代码到你~/。Bashrc或~/。ZSHRC文件,您将不需要再次编写此代码。

正如您所说,所显示的错误可能是以下错误。

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.

如上所述,只需在您的终端中输入'/bin/bash——login'(重启终端后),然后键入命令'rvm use 1.9.3'(例如),它将开始使用相同的版本。

只需执行命令'ruby -v'来确认RVM使用的是ruby的更新版本。

我通过在.bash_profile中添加这一行来修复它:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

我也犯了同样的错误,但这一页上的解决方案似乎都不起作用。对我来说,把rvm可执行文件添加到我的路径就足够了:

PATH=$PATH:/usr/local/rvm/bin/

和拖鞋!

我也遇到过这个问题。最后我在终端上执行了这行。

source ~/.rvm/scripts/rvm

问题解决了。因为这一行将使RVM实例成为特定时间的函数。