3

I have the multi-user version of RVM installed in /usr/local/rvm/bin on Ubuntu 12.10. When I upgraded Ruby from 1.9.3 to 2.0.0 this seems to have caused the following error message to pop up whenever I execute rvm version or similar commands:

$ rvm version
Warning! PATH is not properly set up, '/usr/local/rvm/gems/ruby-2.0.0-p247/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.0.0-p247'.

rvm 1.22.16 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

I have tried the suggestions listed in similar questions, but rvm get head and rvm get head --auto-dotfiles did not help.

I have the following at the very end of my .bashrc:

PATH=$PATH:/usr/local/rvm/bin # Add RVM to PATH for scripting                                                                      

And my path is:

$ echo $PATH
./bin:/usr/local/sbin:/usr/local/bin:/usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p247/bin:/usr/local/rvm/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

$ which rvm
/usr/local/rvm/bin/rvm

$ which ruby
/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby
Community
  • 1
  • 1
George Armhold
  • 30,824
  • 50
  • 153
  • 232

3 Answers3

4

RVM and PATH

RVM expects to find its bin directory first in your PATH. RVM really, really wants to ensure that it takes precedence over any system binaries or gems. To make a system install of RVM happy, your PATH statement should look similar to:

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

whereas you currently have that inverted. This is generally The Right Thing™ to do.

Ignoring the Error

If you really know what you're doing, you can add:

rvm_silence_path_mismatch_check_flag=1

to your /etc/rvmrc or ~/.rvmrc file. This will prevent RVM from complaining about not being first in the PATH, but is very likely to cause problems for most people.

There may be legitimate edge cases where this is necessary, such as having Ruby-related wrapper scripts in ~/bin that you want to take precedence. However, debugging Ruby and RVM will be much harder, so you should remember to check which -a <ruby|gem> as your first troubleshooting step if you have this option enabled.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • Pretty sure that the rvm install process itself (or --auto-dotfiles) added that line as-is to my .bashrc. But I inverted it as you suggested; no dice. – George Armhold Oct 04 '13 at 19:25
  • @CaffeineComa File a ticket. – Jordon Bedwell Oct 04 '13 at 19:40
  • When using the multi-user installation of rvm, rvm is sourced through /etc/profile.d/rvm.sh, before any personal profile files. Is there a Right Way™ to prepend entries relative to the other existing PATH entries *except* those put there by rvm and do this for my own profile only? Re-sourcing the global rvm in .bashrc after doing "export PATH=/some/bin:$PATH doesn't seem to help. – Daniel Jun 02 '14 at 19:06
  • To answer my own comment - mpapis showed me how to do this by splitting the path, adding my entries and rebuilding the path again. A little cumbersome, but now I get the PATH i want! – Daniel Jun 03 '14 at 13:38
0

Your PATH includes ./bin:/usr/local/sbin:/usr/local/bin on beginning, as much as I can agree that it is good to keep /usr/local/sbin:/usr/local/bin on the beginning I need to warn you it is extremely dangerous to keep ./bin at the first place, it is like begging to hijack your computer, this is one of the biggest security issues regarding to distributed work and working with pubic repositories.

Otherwise the answer form @CodeGnome is pretty accurate except this small detail.

mpapis
  • 52,729
  • 14
  • 121
  • 158
0

I've found that it's /etc/profile.d/rvm.sh that seems to be causing the problem. Link to its content: https://gist.github.com/armhold/6832283.

If I chmod it to remove read/execute bits I find that rvm is happy again.

I wonder if there is not an update to this script that should be manually installed...

George Armhold
  • 30,824
  • 50
  • 153
  • 232