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
This may be an old question, but Google led me here and, for posterity sake, thought I'd share.
My problem persisted after many of the recommended solutions above. Like the OP, I installed rbenv and then a ruby version, but my laptop defaulted to system. What I had overlooked was that when I ran:
IOW, it was still defaulting to system. A quick
switched it to the new version.
I came to the same problem. Fixed this by run the "rbenv global" command with "sudo". I think it was something permission problem.
update: I finally found the solution. There was one same file "version" on my mac, which is under "/usr/local/Cellar/rbenv/0.3.0/". I think it was created by mistake occasionally. you should remove it.
Run this command
Add rbenv to bash so that it loads every time you open a terminal
this will solve your problem Reference
I had the same problem, but caused by Homebrew:
Somehow I had installed Ruby via Homebrew too, and the Homebrew path was ahead of the rbenv path in my
$PATH
. Runningbrew uninstall ruby
fixed it for me.rbenv help shell
"Sets a shell-specific Ruby version by setting the 'RBENV_VERSION' environment variable in your shell. This version overrides localapplication-specific versions and the global version. should be a string matching a Ruby version known to rbenv.The special version string 'system' will use your default system Ruby. Run rbenv versions' for a list of available Ruby versions."
Provided rbenv was installed correctly, ruby -v will correspond to
rbenv shell 1.9.3-p125
run:
After I ran that, when i set my local rbenv version:
then my
ruby -v
and myrbenv local
versions coincided.Note: You might also want to exit the directory you're in and then go back into it, i've noticed that was necessary for me in order to get things to work.