$ PATH未正确设置

时间:2016-04-11 15:32:50

标签: ruby version-control rvm homebrew

我刚刚运行'rvm get stable'给出以下错误;

Warning! PATH is not properly set up, '/Users/jamesbkemp/.rvm/gems/ruby-2.2.1/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.2.1'.

在运行'rvm get stable'之前,我将'brew upgrade ruby​​'运行到Ruby 2.2.2。

'echo $ PATH'返回以下内容:

/usr/local/heroku/bin:/Users/user/.rvm/gems/ruby-2.2.1/bin:/Users/user/.rvm/gems/ruby-2.2.1@global/bin:/Users/user/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/user/.rvm/bin:/Users/user/.rvm/bin

我不明白这里的问题是什么或为什么当我运行'ruby -v'时它返回'ruby 2.2.1p85'。

运行'rvm list'会返回以下内容,以及上面详述的相同PATH错误消息;

ruby-2.0.0-p353 [ x86_64 ]
   ruby-2.0.0-p451 [ x86_64 ]
   ruby-2.1.0 [ x86_64 ]
   ruby-2.1.5 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
   ruby-2.2.2 [ x86_64 ]

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

将RVM代码放在$ PATH

的开头

我遇到了同样的问题。我去了终端并输入subl ~/,这会在Sublime Text上打开你的主文件夹(或者你可以使用另一个文本编辑器)。

然后,我点击了以.开头的每个文件,例如.bash_profile.bashrc.mkshrc.zshrc

每当我看到这一行:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

我把它更改为:

export PATH="$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting

这样,RVM代码就在$PATH的开头。然后我退出终端并再次启动它以确保加载了这些配置文件。