Rails - the newest gem is installed but the applicaiton is old

时光怂恿深爱的人放手 提交于 2019-12-11 11:13:43

问题


I'm working on Bluehost. I installed the 3.2.8 gem of rails, and now I get this:

> gem list --local | grep rails
rails (3.2.8)

But:

rails --version
Rails 2.3.11

How can I make the "rails" command use the latest gem? I guess it has something to do with my $PATH variable but I'm pretty much clueless about it.

Also, the gem and rails command give rise to some errors that look like this:

Invalid gemspec in [XXX]: invalid date format in specification: "YYY"

I'm not sure if that's connected (and I'm wondering what causes such errors anyway).


回答1:


Try running this command:

curl -L https://get.rvm.io | bash -s stable --ruby --rails

What it does is install RVM, which maintains separate gems for each version of Ruby installed. The --ruby and --rails arguments tell it to install ruby and rails while installing RVM. RVM installation automatically updates $PATH and any other necessary environment variables.

At the end of installation, it should prompt you to run:

source ~/.rvm/scripts/rvm

which will make those environment variable changes effective immediately. Alternatively, you can log out and then log right back in.

Run rails -v and ruby -v at that point, and you should see them pointing to the new version. Run bundle install from your RoR app's directory and all the gems you need should install in ~/.rvm/gems/ruby-/gems.

At that point, you can delete/uninstall any gems/rails/ruby from before installing RVM.

EDIT on 10/17/2012: Nevermind my answer. Even though it might be possible to get Rails 3.x running with the currently installed Ruby 1.8 (see this Stackoverflow question), you won't be able to run Ruby 1.9.x using Bluehost Shared Hosting. Your only choice (for now) is VPS Hosting.

The reason is that Passenger Phusion is tied to the version of Ruby installed in /usr/lib, which you can't change without root access. Even though you can install any version of Ruby with RVM, you won't get Passenger to talk to it and therefore your rails project won't use its gems.



来源:https://stackoverflow.com/questions/12685808/rails-the-newest-gem-is-installed-but-the-applicaiton-is-old

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!