Darion Miller
Darion Miller

Reputation: 31

Can't change rbenv global ruby version

I switched from RVM to rbenv recently and I can't seem to switch between ruby versions even though 'rbenv versions' tells me I have the version I want to switch to.

Here is what Im doing:

ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

I would like to switch to 1.9.2-p290 so lets make sure I have it in my versions:

ruby versions
1.8.7-p370
1.9.2-p290
1.9.3-p125
1.9.3-rc1

Ok great now that I see I have it lets try and change the global rbenv:

rbenv global 1.9.2-p290
ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

Seems 1.8.7 is still the active global ruby.

So, lets try and make it local in my project. rbenv local 1.9.2-p290

This creates a .rbenv-versions file in my rails project. Great lets try and run bundle:

Gem::InstallError: factory_girl requires Ruby version >= 1.9.2.
An error occurred while installing factory_girl (4.1.0), and Bundler cannot continue.
Make sure that `gem install factory_girl -v '4.1.0'` succeeds before bundling. 

I'm not sure what to do next...

Upvotes: 2

Views: 6096

Answers (2)

juan Isaza
juan Isaza

Reputation: 3987

If $ echo $PATH

has no .rbenv then execute:

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

and restart shell.

Upvotes: 3

Jankeesvw
Jankeesvw

Reputation: 710

I solved this today on a (OSX) computer of a friend, the problem probably is that you have RVM and Rbenv installed at the same time, first you have to make sure RVM is removed;

In the terminal execute:

sudo rm -rf ~/.rvm

When this is done, reopen the terminal. Then try ruby -v, the version you see is probably the system version ruby 1.8.7. Then try again to select the right Ruby version with Rbenv:

rbenv global 2.0.0-p247

Also, be sure Rbenv is in your path:

echo $PATH
=> /Users/jankeesvw/.rbenv/bin:/Users/jankeesvw/.rbenv/shims:/Users/jankeesvw/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin

If this Rbenv is not in your path, follow the instructions on the Rbenv github page

Upvotes: 5

Related Questions