rbenv can't change global ruby version

qodot picture qodot · Jul 14, 2014 · Viewed 25.8k times · Source

My Mac OS X has a default ruby.

$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

I installed rbenv and ruby version 2.1.2.

$ rbenv versions
  system
* 2.1.2 (set by /Users/sdw/.rbenv/version)

and I tried to set the global ruby version to 2.1.2, but nothing happened.

$ rbenv global 2.1.2
$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

So I tried to do the same thing with command sudo, but the result is the same.

$ sudo rbenv global 2.1.2
$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

How can I change my global ruby version to 2.1.2? I never installed rvm or other ruby version managing system.

Answer

spickermann picture spickermann · Jul 14, 2014

Did you add the following lines to your ~/.bash_profile?

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

See: https://github.com/sstephenson/rbenv#installation