RVM Warning! PATH is not properly set up

拥有回忆 提交于 2019-12-02 15:51:36

I have the same problem with rvm 1.25.26.

solution:

I've modified ~/.bashrc as follows:

## rvm
PATH="$GEM_HOME/bin:$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
[ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm

causing:

Warning is fired at __rvm_path_match_gem_home_check() function in $HOME/.rvm/scripts/functions/cli.

If the beginning of $PATH does not start from $GEM_HOME/bin, a warning message is displayed.

__rvm_path_match_gem_home_check()
{
  (( ${rvm_silence_path_mismatch_check_flag:-0} == 0 )) || return 0
  [[ -n "${GEM_HOME:-}" ]] || return 0
  case "$PATH:" in
    ($GEM_HOME/bin:*) true ;; # all fine here
    (*:$GEM_HOME/bin:*)
      __rvm_path_match_gem_home_check_warning "is not at first place"
      ;;
    (*)
      __rvm_path_match_gem_home_check_warning "is not available"
      ;;
  esac
}

In my case, Heroku had added the following to my .bashrc:

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

Notice how it's prepending itself to the path. All I had to do was switch it around to:

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

And my problem was solved!

If you don't have Heroku, look for anything else that may be prepending itself to your path. Really, RVM just wants to make sure it has a fair chance to load Ruby before any gems that include themselves in the path get loaded.

The solution was to run

$rvm install ruby-head
$rvm use ruby-head

with an optional $rvm docs generate-ti

I was using an outdated version of Ruby on my system, updating it to the current version fixed it.

Search your config files for:

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

Replace that line with:

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

To make sure the RVM code is at the start of your $PATH. Also make sure no other code puts itself at the start of $PATH.

Because I was using the ubuntu version of rvm, I needed to put this in my .profile:

PATH="$GEM_HOME/bin:/usr/share/rvm/bin:$PATH" # Add RVM to PATH for scripting
[ -s /usr/share/rvm/scripts/rvm ] && source /usr/share/rvm/scripts/rvm

It seems, and the end of .bashrc, you need to guarantee the rvm path is at the beginning of $PATH

Right. I'dumping this answer as I spent hours researching with no success. I hope this will save someone else some time.

My problem was having 2 ruby heads installed and apparently, the ruby version was also an issue.

➜ rvm list                   
Warning! PATH is not properly set up, '/home/ma/.rvm/gems/ruby-1.8.7-head/bin' is not at first place.
         Usually this is caused by shell initialization files. Search for 'PATH=...' entries.
         You can also re-add RVM to your profile by running: 'rvm get stable --auto-dotfiles'.
         To fix it temporarily in this shell session run: 'rvm use ruby-1.8.7-head'.
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.

rvm rubies

=> ruby-1.8.7-head [ x86_64 ]
   ruby-1.8.7-p374 [ x86_64 ]
   ruby-2.3.0 [ x86_64 ]
   ruby-2.4.0 [ x86_64 ]
 * ruby-head [ x86_64 ]

# => - current
# =* - current && default
#  * - default

In this case, (trying all the above solutions, this and this) setting my default to ruby-head [ x86_64 ] and restarting the terminal the Warning! AND my current ruby version was persisting as the above snippet shows.

To fix that:

rvm remove ruby-1.8.7-head

Now, if I restart the terminal:

➜ rvm list                  

rvm rubies

   ruby-1.8.7-p374 [ x86_64 ]
   ruby-2.3.0 [ x86_64 ]
   ruby-2.4.0 [ x86_64 ]
=* ruby-head [ x86_64 ]

# => - current
# =* - current && default
#  * - default
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!