Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Rails to use the version of Ruby (managed with rbenv) that I want?

I installed rbenv and ruby-build. Then I installed ruby 1.9.2p290. Everything was looking good.

$ cd my_rails_app
$ ruby -v
1.9.2p290
$ rails server
...
[2011-10-04 13:51:01] INFO  WEBrick 1.3.1
[2011-10-04 13:51:01] INFO  ruby 1.8.7 (2010-01-10) [universal-darwin11.0]
...

But when I run my app, it is still using ruby 1.8.7. (methods that exist in 1.9 fail). Everything in rails/console acts like 1.8, and within IRB acts like 1.9.

How can I force my app to use 1.9?

I am familiar with RVM, I'm specifically asking about rbenv.

like image 587
Nathan Manousos Avatar asked Oct 04 '11 20:10

Nathan Manousos


1 Answers

Did you install Rails with bundle install? If so, note that Bundler does not add the executables into Ruby's executable directory.

Instead, use binstubs or bundle exec (documentation):

bundle exec rails server

In case you did not install Rails with Bundler, you probably should do an rbenv rehash to update the executable shims. Then rails server should work fine. However, this will only work if Rails was installed with Rubygems directly, so it is an unreliable way of invoking Rails.

like image 116
molf Avatar answered Sep 22 '22 17:09

molf