Getting "Warning! PATH is not properly set up" when doing rvm use 2.0.0 --default

73,183

Solution 1

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.

Solution 2

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.

Solution 3

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"

Solution 4

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

Solution 5

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.

Share:
73,183
Michael Durrant
Author by

Michael Durrant

rails ruby rspec rock

Updated on May 16, 2020

Comments

  • Michael Durrant
    Michael Durrant about 4 years

    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
    Michael Durrant over 10 years
    No. It worked and I moved on :) Plenty more interesting fish to fry :)
  • reneruiz
    reneruiz over 10 years
    Seems counter-intuitive to move to the bottom if RVM wants to be at the top of the chain?
  • TimeEmit
    TimeEmit about 10 years
    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.
  • Kyle Suss
    Kyle Suss about 10 years
    I put it at the bottom of my .bash_profile as I had redefined path several times. This also worked.
  • kevindeleon
    kevindeleon over 9 years
    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.
  • Ain Tohvri
    Ain Tohvri over 9 years
    God knows what kind of command line installer pushed it in. They tend to pollute it :(
  • Brett Bim
    Brett Bim over 9 years
    This worked on Mavericks, had to restart the terminal to complete the fix.
  • Barry Kelly
    Barry Kelly about 9 years
    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.
  • TrinitronX
    TrinitronX about 9 years
    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)
  • NSTJ
    NSTJ over 8 years
    this worked well for me after restarting the terminal
  • JohnRDOrazio
    JohnRDOrazio over 8 years
    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.
  • Dan L
    Dan L over 8 years
    This is a cleaner solution, IMO, with the updates to RVM.
  • IIllIIll
    IIllIIll over 8 years
    This only solves the problem for the current shell session so it's not exactly the best answer.
  • Ralph Callaway
    Ralph Callaway over 8 years
    this is definitely the right solution, but if you just do rvm reset it will do this for you automatically ...
  • applejack42
    applejack42 almost 8 years
    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.
  • Admin
    Admin over 7 years
    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. :)
  • Dmitri
    Dmitri over 7 years
    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.
  • Albert Català
    Albert Català over 7 years
    Yes this is the best solution, because is clear and specify where to put the export. Thanks!!!
  • Aaron Henderson
    Aaron Henderson over 7 years
    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!
  • Pedro José Piquero Plaza
    Pedro José Piquero Plaza about 7 years
    Thanks, I'm glad to help
  • Pysis
    Pysis almost 7 years
    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: pastebin.com/1jUCSGnP
  • Pysis
    Pysis almost 7 years
    Ah, probably when I was running commands, they were using the bash interpreter, and I should have checked those configuration files as well..
  • Pysis
    Pysis almost 7 years
    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..
  • SylvainB
    SylvainB over 6 years
    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!
  • rubyandcoffee
    rubyandcoffee over 6 years
    This worked for me - and I've had this issue for a long time!
  • Apurva Mayank
    Apurva Mayank almost 6 years
    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
  • Christopher Warrington
    Christopher Warrington over 5 years
    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.
  • sambecker
    sambecker over 5 years
    Thanks @RalphCallaway after the above didn't work rvm reset did!
  • raulp
    raulp almost 5 years
    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.
  • AkaZecik
    AkaZecik almost 5 years
    @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.
  • raulp
    raulp almost 5 years
    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.
  • AkaZecik
    AkaZecik almost 5 years
    @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 :)
  • droid001
    droid001 over 4 years
    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"
  • Muhamed Huseinbašić
    Muhamed Huseinbašić over 4 years
    rvm help returns quite scary hint for rvm reset: remove all default and system settings 😄
  • medBouzid
    medBouzid over 3 years
    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