Search code examples
rubyrbenv

Why cant I change my ruby version with rbenv?


I am trying to change my version of ruby and i have installed version 2.1.9. But no matter what I do ruby still claims to be on an older version:

Solomons-MacBook-Air:~ soldenh$ rbenv local 2.1.9
Solomons-MacBook-Air:~ soldenh$ rbenv global 2.1.9
Solomons-MacBook-Air:~ soldenh$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Solomons-MacBook-Air:~ soldenh$ rbenv versions
system
* 2.1.9 (set by /Users/soldenh/.ruby-version)
2.3.1
2.4.0

How can I fix this?


Solution

  • You probably forgot to set add rbenv's bin directory early in your $PATH. Because of this, you are using your system's Ruby instead of the one installed by rbenv.

    To ensure rbenv's binaries are added to your PATH, you can add the initialization to your .bash_profile file (depending on which shell you use and where exactly you installed rbenv to).

    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
    

    Please have a look at the installation instructions for rbenv at https://github.com/rbenv/rbenv#installation, esp. point 2.