我刚安装了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。


当前回答

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

source ~/.rvm/scripts/rvm

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

其他回答

您需要运行以下命令

$ source ~/.rvm/scripts/rvm

然后运行这个

$ type rvm | head -n 1

如果你得到

rvm is a function

问题解决了。

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

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

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

在Mac OSX 10.8 Mountain Lion操作系统上安装Ruby 1.9.3-p125

You've already installed the latest XCode (>= 4.3) and and the command line Objective-C compiler "clang". You must run the "bash" shell for this procedure to work. Go to System Preferences Click on "Users & Groups" Click the lock on the bottom left of the panel and enter your password to unlock it. "Ctrl-Click" on your user icon in the left pane of the panel and choose "Advanced Options..." Change the Login Shell to "/bin/bash" Close the preferences Open a terminal window (press command+spacebar and type in "terminal") Follow the instructions at:

http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/

注:

要安装ruby,你可能需要指定clang编译器: $ RVM install 1.9.3p125——with-gcc=clang 如果RVM抱怨没有找到/usr/local/rvm,你需要创建一个链接: $ ln -s /Users/[用户名]/。rvm /usr/local/rvm

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

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

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

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

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

以上答案都是正确的。但当我面对同样的问题时,解决方案如下:

Update ZSH. (Tried to update directly din't work for some reason. So uninstalled and reinstalled updated version from here) Set default shell as zsh (i.e. if you prefer zsh) using sudo chsh -s $(which zsh) $USER Ensure that the following code is at the bottom of your .zshrc after you have installed the latest RVM probably using CURL from official RVM site [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" source ~/.profile MOST IMPORTANT POINT: Ensure that in your .zshrc file every export to PATH is appended with :$PATH. Which i believe was the root of my problems even after following the above steps. post this all my problems of RVM Not being a function went away. If it still does not work, give some error trace over here. After a few hours of struggle to solve this issue, i'm sure i must have seen all related errors.

希望能有所帮助。干杯!