139

Above doesn't work first time, works 2nd time.

Try to set ruby version to 2.0.0 for any new shell windows.

Doing

$ rvm use 2.0.0 --default

gives

Warning! PATH is not properly set up, '/home/durrantm/.rvm/gems/ruby-1.9.3-p125/
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 --au
to-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-1.9.3-p125'
.
Using /home/durrantm/.rvm/gems/ruby-2.0.0-p247

Then doing the same

$ rvm use 2.0.0 --default

now gives no error, i.e.

$ rvm use 2.0.0 --default
Using /home/durrantm/.rvm/gems/ruby-2.0.0-p247
durrantm.../durrantm$ 

but new windows are still giving me ruby 1.9.3, not 2.0.0

My .bashrc file has in it:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/durrantm/.rvm/scripts/rvm" ]] && . "/home/durrantm/.rvm/scripts/rvm"

My .bash_profile has:

source ~/.profile
case $- in *i*) . ~/.bashrc;; esac

Trying

rvm get stable

seems to work but at the end of a lot of green output shows:

Could not update RVM, get some help at #rvm IRC channel at freenode servers.

A new terminal windows with rvm list rubies shows this:

$ rvm list rubies
Warning! PATH is not properly set up, '/home/durrantm/.rvm/gems/ruby-1.9.3-p125/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-1.9.3-p125'.

rvm rubies

=> ruby-1.9.3-p125 [ x86_64 ]
   ruby-1.9.3-p194 [ x86_64 ]
 * ruby-2.0.0-p247 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497

17 Answers17

209

I was stuck after I uninstalled rvm with

rvm implode

then after reinstalling rvm it received the same error message. After looking through wayne seguin's git hub page. He lists tools on his page and recommended using

rvm reset 

after an installation. This fixed my error message. No PATH edits needed.

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
brandoncontreras
  • 2,101
  • 1
  • 10
  • 4
  • 14
    After checking & re-checking my `~/.bashrc`, `~/.bash_profile`, running `rvm get stable --auto-dotfiles`, re-checking `~/.bashrc`, `~/.bash_profile`, and `~/.profile` many times... this answer finally fixed it! Ran: `rvm reset` and it got rid of the warnings! (IMHO... RVM is way too finicky about being first in path... If I set something else first in my path I know what I'm doing) – TrinitronX Mar 13 '15 at 21:03
  • 21
    this worked for me! no PATH edits needed, just `rvm reset` (the message will show one last time), now anytime I issue an rvm command no more PATH warnings. – JohnRDOrazio Oct 10 '15 at 19:40
  • 1
    When I use rvm reset the issue in the terminal where I ran rvm reset is resolved. However, when I move to the new terminal the error/warning persists unless I don't run rvm reset again – Apurva Mayank Aug 07 '18 at 05:36
  • `rvm help` returns quite scary hint for `rvm reset`: **remove all default and system settings** – Muhamed Huseinbašić Feb 12 '20 at 20:36
  • 1
    After I run that, I did `rvm gemset list` but all my gemsets disappeared, I thought they were deleted, but you have to choose your ruby version again (i.e: `rvm use 2.7.0`) and your gemsets will appear again – medBouzid Dec 26 '20 at 21:17
182

The answer was to put this:

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

**at the BOTTOM** (last line - important!) of my .bashrc file. I had it in my .bash_profile file (I am on Ubuntu) and that only partially worked leading to the confusing errors.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • 2
    Seems counter-intuitive to move to the bottom if RVM wants to be at the top of the chain? – reneruiz Feb 06 '14 at 00:57
  • 10
    rvm needs to be at the bottom of the file in case there are other lines in .[ba|z]shrc that redefine path. `export PATH="/usr/local/bin:/usr/local/sbin:$PATH"` for Homebrew is probably a common one that comes into conflict with rvm. – TimeEmit Mar 05 '14 at 20:54
  • 4
    I put it at the bottom of my .bash_profile as I had redefined path several times. This also worked. – Kyle Suss Mar 29 '14 at 02:24
  • 1
    this worked well for me after restarting the terminal – NSTJ Sep 12 '15 at 03:25
  • 26
    this is definitely the right solution, but if you just do `rvm reset` it will do this for you automatically ... – Ralph Callaway Jan 26 '16 at 03:13
  • f-ing awesome! struggled with this and dealt with a broken rvm for days. I had ended up with the same rvm source statement in bashrc, bash_profile, and .profile, and somehow they clobbered each other. I have now blanked out my bashrc and profile and just have everything in my .bash_profile. Not sure if that's a good practice or not but I'm not a bash scripter and I don't need it to do much, so 1 simple file made things much more straightforward. Thank you for your very well thought out question AND answer. Cheers! – Aaron Henderson Jan 12 '17 at 16:41
  • This worked for me - and I've had this issue for a long time! – nope2023 Nov 13 '17 at 21:20
  • Like @AaronHenderson, I cleared out my `.bashrc` and my `.profile` files. Then I ran `rvm --default use 2.5.0` and restarted terminal. That fixed it for me. I had tried many other solutions, but it was the clearing out of the other files and then re-running the default code that did it for me. – Christopher Warrington Jan 05 '19 at 22:24
  • Thanks @RalphCallaway after the above didn't work `rvm reset` did! – sambecker Feb 07 '19 at 16:45
  • 1
    As of Ubuntu 19.04 and rvm v.1.29.9 got it to work with: ```[[ -s "/usr/share/rvm/scripts/rvm" ]] && source "/usr/share/rvm/scripts/rvm" ``` – droid001 Aug 19 '19 at 19:36
56

Maybe is not the best way to resolve this, but I added this line at the botton of my .zshrc (it will work in .bashrc too!)

export PATH="$GEM_HOME/bin:$PATH"
  • This is a cleaner solution, IMO, with the updates to RVM. – Dan L Nov 06 '15 at 15:16
  • I disagree, I think this is the best way to resolve this :) I had to put this as the last line of my .bash_profile as it runs last and has other path declarations in it. – applejack42 Jul 12 '16 at 05:23
  • This is really one of the best solution to resolve this issue. Spent nearly 3 hours and finally about to give up :D you the man. :) –  Aug 29 '16 at 17:23
  • I added mine to my ~/.profile, which is loaded by the last line of ~/bash_profile and made sure there werer no references to $PATH in any other file. This way, it will work in Bash and get picked up by other shells. – Dmitri Sep 17 '16 at 18:42
  • Yes this is the best solution, because is clear and specify where to put the export. Thanks!!! – Albert Català Oct 27 '16 at 15:58
  • Thanks, I'm glad to help – Pedro José Piquero Plaza May 12 '17 at 12:29
  • Using Ubuntu 16.04 (x64) in a KDE/Plasma 5 environment, this solution was the only one working for me. Adding this to `~/.profile` did nothing but as the last line of `~/.bashrc`, it worked like a charm. Thank you! – SylvainB Aug 31 '17 at 09:51
24

I tried Michael Durrant's solution and it didn't work for me. but I ran rvm get stable --auto-dotfiles and it began working as desired.

Hope it helps

Sparkmasterflex
  • 1,837
  • 1
  • 20
  • 33
  • This worked on Mavericks, had to restart the terminal to complete the fix. – Brett Bim Feb 12 '15 at 12:17
  • 1
    On Mac 10.12.3 with iTerm2 3.0.15, fish 2.5.0, and the `rvm default` at the bottom of my `config.fish` file. the command `rvm reset` did not help when keeping the terminal window open. This command did work. My output: https://pastebin.com/1jUCSGnP – Pysis Jun 13 '17 at 14:32
  • Ah, probably when I was running commands, they were using the `bash` interpreter, and I should have checked those configuration files as well.. – Pysis Jun 13 '17 at 14:40
  • Nope, it was still broken in other terminal windows, even after restarting iTerm, and checking any number of profile scripts did not help, so I imploded removed all config lines, restarted my computer, reinstall RVM with the fish function integration, and enabled the one `rvm default` line. It's better now.. – Pysis Jun 13 '17 at 20:22
9

This isn't an answer to the question asked, but to the related question that most commenters/responders have asked -- Why do you need to put the rvm line at the bottom of the shell rc file?

The answer is simple.

  1. The rvm code which is loaded puts the rvm ruby binary directories at the "front" of $PATH, and
  2. .bashrc (or equivalent for your default shell) is read and interpreted line-by-line from top to bottom.

So imagine the following scenario :

$ echo $PATH
  /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin 

$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
  /Users/sankalp/.rvm/gems/ruby-1.9.3-p547/bin:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547@global/bin:/Users/sankalp/.rvm/rubies/ruby-1.9.3-p547/bin:/Users/sankalp/bin:/usr/texbin/:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

$ export PATH=<something>:$PATH
$ echo $PATH
  <something>:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547/bin:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547@global/bin:/Users/sankalp/.rvm/rubies/ruby-1.9.3-p547/bin:/Users/sankalp/bin:/usr/texbin/:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

Clearly if something is present in the shell init file after the RVM line and makes any changes to $PATH, more specifically if it prepends directories to $PATH, then those changes will push the directories added by rvm down from their first position. RVM, when invoked, will find that its ruby binary directories are not at the very beginning of $PATH and BAM! you'll get the warning :) .

I hope that makes things clear.

Sankalp
  • 499
  • 7
  • 4
6

Just adding my experience: if you're using .bash_profile, check if .bashrc is not interfering. Killing .bashrc in favour of single Bash configuration by .bash_profile works out in this case.

Ain Tohvri
  • 2,987
  • 6
  • 32
  • 51
  • 1
    This solved my problem. I'm not even sure how .bashrc got there as all my configs are in .bash_profile. Does rvm put something in bashrc on install? I would assume so considering that bashrc only had one line in it and it was to do with rvm. – kevindeleon Feb 04 '15 at 17:01
  • 1
    God knows what kind of command line installer pushed it in. They tend to pollute it :( – Ain Tohvri Feb 05 '15 at 12:48
  • 3
    This isn't a general solution, FWIW. `.bashrc` is executed for every nested interactive shell; `.bash_profile` is only executed on the first bash shell entered, i.e. the login shell. Variables should generally be set in `.bash_profile`, whereas functions, aliases etc. (stuff that doesn't get transmitted with normal inherited environment) should be set in `.bashrc`. – Barry Kelly Mar 09 '15 at 14:12
5

I have a follow-up question to this (wish I could simply add comment - but I don't have enough credits). I had this very same issue - and when I followed the rvm script that was suggested using --auto-dotfiles, I got into trouble as it somehow the shell script deleted my .bashrc_profile file.

Anyway, I eventually came around to the same answer listed above, putting this line at the bottom of .bashrc file. [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Did you happen to find why that works the way it does, and not with the line in the middle of .bashrc file? Do you have some clarity around the way Unix is loading the environment variable that makes RVM work in one instance and not in another?

David Kim
  • 866
  • 9
  • 11
5

I was facing same issue. I found that in bashrc file

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

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

multiple entries for rvm. I commented one entry and its working fine.

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

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
Deepak Kabbur
  • 774
  • 14
  • 25
4

I cleaned out everything that had a .rvm in it from my PATH= line in my .zshrc

That fixed the issue for me, where the other answers here (sourcing the rvm script, or getting stable with auto dotfiles) didn't.

Caleb
  • 1,452
  • 15
  • 20
2

I have found this command to be very usefull. It solve my case. So if anyone is having the same issue, give this a try: rvm get stable --auto-dotfiles

castro4000
  • 21
  • 1
2

I ended up removing ~/.profile, ~/.bashrc and ~/.zshrc.

Basically I only kept ~/.bash_profile on my mac. And it works.

I think in my case, there are:

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

in these files, and those duplicate settings confused rvm

Steven Yue
  • 966
  • 1
  • 8
  • 16
2

Disclaimer

Cuz I mainly develop using python, so I am not sure the would this workaround give you a correct ruby env or just change the path and get rid of the warning

Background

In my case, I installed rvm first, and then pyenv later. The config for both of them will change $PATH. From the warning, it seems that rvm always want to be the first in the path

$ echo $PATH

$HOME/.rvm/gems/ruby-2.6.3/bin: ......

But if you add eval "$(pyenv init -)" as required by pyenv, it will change your $PATH to

$ echo $PATH

$HOME/.pyenv/shims:$HOME/.rvm/gems/ruby-2.6.3/bin: ......

My workaround

$ rvm use system # Switch back to system ruby

$ rvm use ruby-2.6.3 # Switch to the version you need to use

rvm will change the path to what it likes then you won't see the annoying warning again.

infinity_coding7
  • 434
  • 5
  • 16
1

rvm install ruby-head Fixed the issue for me - little time consuming but did the trick. Not sure if that made any unpronounced updates to my bash files.

0

It worked after commenting top 2 duplicate lines and adding them at bottom. Don't forget to restart the terminal for it to work.

#[[ -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*
export PATH="/usr/local/opt/postgresql@9.6/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/postgresql@9.6/lib"

[[ -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*
Dave
  • 4,376
  • 3
  • 24
  • 37
0

You can add

rvm_silence_path_mismatch_check_flag=1

to your ~/.rvmrc file. That's what the warning message now suggests.

AkaZecik
  • 980
  • 2
  • 11
  • 16
  • 2
    This is just ignoring the message, not fixing it, which is what the user is asking for. Plus, for a new project, the problem will reappear. – raulp Jul 24 '19 at 14:09
  • @ma3x Actually, the OP only stated a problem without stating a question, so I consider 'ignoring' a _warning_ message a valid suggestion. Also, I don't understand the part about new projects. – AkaZecik Jul 25 '19 at 00:14
  • 1
    Even if there's no question mark you can definitely understand from the context that he's trying to fix the error, not hide it :) Plus, your answer is incomplete because that's just a part from what the warning message suggests. Initially, it suggests to get the latest stable RVM and autodot your files. For the new projects that was my mistake because I wanted to refer to new gemsets. – raulp Jul 25 '19 at 10:13
  • @ma3x Thanks for your insights :) Perhaps it's just that our ways of reasoning differ, but after reading the question and other answers, I came to a conclusion that the OP simply wants to get rid of this warning. I want to emphasize again that this is not an _error_, it's a _warning_. And because enforcing an order of paths in `PATH` sounds intrusive to me, and at most _protective_, I decided to post this answer. I will take time to rethink my answer and improve it based on your comments :) – AkaZecik Jul 25 '19 at 11:16
-1

For RVM to work properly, you have to check the 'Run command as login shell' checkbox on the Title and Command tab of gnome-terminal's Edit ▸ Profile Preferences menu dialog, in case the menu is missing right click the terminal app and navigate Profiles ▸ Profile Preferences.

https://rvm.io/integration/gnome-terminal

-3

I FIXED THIS PROBLEM. TRY USE COMMAND LIKE THIS:

rvm use 2.0.0-p353

ADD -p353 or other you version detail to line end