开发者

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

开发者 https://www.devze.com 2023-04-10 10:21 出处:网络
I installed rbenv and ruby-build. Then I installed ruby 1.9.2p290. Everything was looking good. $ cd my_rails_app

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 开发者_StackOverflow社区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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消