I installed rbenv according to the github directions. I am running OSX but I have tried this on a Ubuntu 12.04 VM and got the same results. The following is what i get in my terminal when I try to change ruby versions:
rbenv versions
* 1.9.3-p0 (set by /Users/user/.rbenv/version)
1.9.3-p125
rbenv global
1.9.3-p0
rbenv rehash
ruby -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
which ruby
/usr/bin/ruby
Anyone have any ideas as to why rbenv isn't switching the ruby version like it thinks it is? Also there is no .rbenv file in the local directory that would be causing the ruby version to default to 1.8.7
rbenv local
rbenv: no local version configured for this directory
Make sure the last line of your
.bash_profile
is:In my case changing the
~/.zshenv
did not work. I had to make the changes inside~/.zshrc
.I just added:
at the top of
~/.zshrc
, restarted the shell and logged out.Check if it worked:
When I had these symptoms, the problem turned out to be that install had failed halfway through for the new Ruby version I was trying to switch to, without me noticing. The fix was to delete & reinstall it.
(This meant that even though ruby 1.9.3 showed up in the rbenv list of available versions, it didn't have an executable on the path where rbenv assumed it would. Since rbenv tries to change your ruby version just by prepending a location to your path, if there's nothing actually in the location it prepends, your OS will happily continue searching your default path and find your system version, in my case like the question's 1.8.7.)
As for me the easiest way to use
rbenv
along withzsh
is addingrbenv
to plugins section in.zshrc
config. In my case it looks similar to:After that there're no problems when installing, switching, using ruby versions with help of
rbenv
.Mind to restart your terminal session after made changes.
I fixed this by adding the following to my ~/.bash_profile:
This is what is documented at https://github.com/sstephenson/rbenv.
From what I can tell there is no ~/.rbenv/bin directory, which was mentioned in the post by @rodowi.
I forgot to delete rvm before installing rbenv. I deleted rvm and re-installed rbenv, but system still wasn't using the version of Ruby being designated as global by rbenv. I tried shutting Terminal, but it only worked once I restarted the whole machine.