RVM PATH 未正确设置

RVM PATH is not properly set up

我最近 运行 在尝试升级我的 ruby 版本时遇到来自 rvm 的以下错误。

Warning! PATH is not properly set up, '/home/sam/.rvm/gems/ruby-2.2.1/bin' is not at first place,

我的echo $PATH如下:

/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1@global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin

我的 .bashrc 中有以下几行

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

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

而 .bash_profile 有:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile


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

而我的rvm info如下

Warning! PATH is not properly set up, '/home/sam/.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'.

ruby-2.2.1:

  system:
    uname:       "Linux bitey0asus 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "ubuntu/14.04/x86_64"
    bash:        "/bin/bash => GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "10 minutes 55 seconds ago"
    path:         "/home/sam/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.2.1p85"
    date:         "2015-02-26"
    platform:     "x86_64-linux"
    patchlevel:   "2015-02-26 revision 49769"
    full_version: "ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]"

  homes:
    gem:          "/home/sam/.rvm/gems/ruby-2.2.1"
    ruby:         "/home/sam/.rvm/rubies/ruby-2.2.1"

  binaries:
    ruby:         "/home/sam/.rvm/rubies/ruby-2.2.1/bin/ruby"
    irb:          "/home/sam/.rvm/rubies/ruby-2.2.1/bin/irb"
    gem:          "/home/sam/.rvm/rubies/ruby-2.2.1/bin/gem"
    rake:         "/home/sam/.rvm/rubies/ruby-2.2.1/bin/rake"

  environment:
    PATH:         "/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1@global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin"
    GEM_HOME:     "/home/sam/.rvm/gems/ruby-2.2.1"
    GEM_PATH:     "/home/sam/.rvm/gems/ruby-2.2.1:/home/sam/.rvm/gems/ruby-2.2.1@global"
    MY_RUBY_HOME: "/home/sam/.rvm/rubies/ruby-2.2.1"
    IRBRC:        "/home/sam/.rvm/rubies/ruby-2.2.1/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

我找到了类似问题的解决方案但显然不够接近(建议的解决方案没有效果)。

无论如何,如果有人有任何想法,我将不胜感激。我对 rvm 的来龙去脉一无所知,所以我在这里有点一头雾水。提前致谢

编辑:

我尝试颠倒 .bashrc 中两条 rvm 行的顺序,但这对错误没有帮助,也没有改变 echo $PATH.

显示的顺序

您的 PATH 不是以 /home/sam/.rvm/gems/ruby-2.2.1/bin 开头,因为您在 Heroku 工具带路径前面有一行。

您可以在您的终端中通过 运行 检查这是真的:

PATH=/home/sam/.rvm/gems/ruby-2.2.1/bin:$PATH rvm info

它不应该抱怨。 问题来自 Heroku toolbelt 以 rvm 不关心的方式修改你的环境。 根据 this post,解决方法是像这样更改 .bashrc

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

您可以从 .bash_profile

中删除 rvm 行

为了解决这个问题,我刚刚更改了我的 .profile 文件:

PATH="$HOME/bin:$HOME/.local/bin:$PATH"

PATH="$PATH:$HOME/bin:$HOME/.local/bin"