How do I “force” my Rails 3 app to use 1.9.2

2019-06-03 06:12发布

I have setup Rails 3.0.3 and installed Ruby 1.9.2 with rvm and set rvm to use 1.9.2 by default.

However, when I create a new rails app and check the environmental variables it still reflects ruby 1.8.7, how do I update this to 1.9.2?

3条回答
你好瞎i
2楼-- · 2019-06-03 06:16

With RVM, there is actually an easier way to set the default Ruby interpreter without modifying the path directly. Just run the following command

rvm --default use 1.9.2
查看更多
Melony?
3楼-- · 2019-06-03 06:27

One of the best ways of handling this, particularly if you have to deal with rails 2 apps on the same system, is with RVM -- using it, you can can easily install multiple rubies (and sets of gems to go along with them), and switch between them with e.g. rvm use 1.9.2. You can even set it up to automatically switch to the right ruby when you cd into a project directory, described here.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-06-03 06:33

You are probably executing an old 1.8.7 rails binary that is being found first in your UNIX search path.

You can type which rails at the command line to see which rails executable you are running. On my machine I get:

/Users/scott/.rvm/gems/ruby-1.9.2-p136/bin/rails

You can also check your binary search path by typing echo $PATH

If you get a result from which rails that looks something like:

/blah/blah/gems/ruby-1.8.7/bin/rails

... then you need to remove the old rails binary from your path, or use the old 1.8.7 ruby to uninstall the rails gems, so that they are not found and executed.

Once you have done this, the next time you try to execute rails s, the 1.9.2 version of the rails binary should be executed.

查看更多
登录 后发表回答