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
First step is to find out which ruby is being called:
which ruby
Your system says:
/usr/bin/ruby
This is NOT the shim used by rbenv, which (on MacOS) should look like:
/Users/<username>/.rbenv/shims/ruby
The shim is actually a script that acts like a redirect to the version of ruby you set.
rbenv global 1.9.3 rbenv local --unset rbenv shell --unset
I recommend that for trouble shooting you unset the project specific "local" version, and the shell specific "shell" version and just test using the "global" version setting which is determined in a plain text file in ~/.rbenv/verion which will just be the version number "1.9.3" in your case. You can do "ls -laG" in the root of your project folder (not the home folder) to make sure there is no longer a ".ruby-version" file there.
You can use "rbenv versions" to identify which version rbenv is set to use (and the location and name of the file that is setting that).
rbenv versions
NONE OF THAT MATTERS: until you set the path correctly.
Use this to make sure your *MacOS will obey you:
eval "$(rbenv init -)"
Followed by:
which ruby
To make sure it looks like: /Users//.rbenv/shims/ruby
Then add the line to your profile so it runs each time you open a new terminal window:
~/.bash_profile eval "$(rbenv init -)"
There are other ways to modify the path, feel free to substitute any of them instead of running the rbenv init.
NOTE: reinstall Rails with:
gem install rails
If you were trying to run Ruby on Rails, then you need to have this all working first, then install the rails gem again. A previous install of Rails will use a hard coded path to the wrong ruby and several other things will be in the wrong place, so just install the gem again.
P. S. If your MacOS won't obey you (*mentioned above) then you may have to find another way to modify your path, but that's unlikely to be a problem because "Macs just work" ;)