开发者

Missing Rails Gem

I know this question has been asked multiple times on this site, but after digging through other answers, I am still coming up blank on how to resolve this.

I just pulled copy of a rails app from a production server, and I get the following error:

Missing the Rails 2.3.4 gem. Please gem install -v=2.3.4 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

rails 2.3.4 is in my gem list:

*** LOCAL GEMS ***

actionmailer 开发者_运维知识库(2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.3.6)
actionpack (2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activerecord (2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.15.6)
activeresource (2.3.8, 2.3.5, 2.3.4, 2.2.2)
activesupport (2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.4.4)
acts_as_ferret (0.4.3)
authlogic (2.1.6)
capistrano (2.5.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
dnssd (0.6.0)
fastercsv (1.5.4)
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
gemcutter (0.6.1)
google-spreadsheet-ruby (0.1.2)
highline (1.5.0)
hpricot (0.6.164)
libxml-ruby (1.1.2)
mongrel (1.1.5)
mysql (2.8.1)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.1)
net-ssh (2.0.4, 1.1.4)
net-ssh-gateway (1.0.0)
nokogiri (1.4.4)
oauth (0.4.4)
packet (0.1.15)
prawn (0.8.4)
prawn-core (0.8.4)
prawn-fast-png (0.2.3)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.2.1, 1.1.0, 1.0.1)
rails (2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.2.6)
rake (0.8.3)
RedCloth (4.1.1)
rmagick (2.13.1)
roo (1.9.3)
ruby-ole (1.2.11.1)
ruby-openid (2.1.2)
ruby-yadis (0.3.4)
rubynode (0.1.5)
rubyzip (0.9.4)
spreadsheet (0.6.5.0)
sqlite3-ruby (1.2.4)
termios (0.9.4)
xmpp4r (0.4)

And gem list -d rails looks like this:

*** LOCAL GEMS ***

rails (2.3.8, 2.3.5, 2.3.4, 2.2.2, 1.2.6)
    Author: David Heinemeier Hansson
    Rubyforge: http://rubyforge.org/projects/rails
    Homepage: http://www.rubyonrails.org
    Installed at (2.3.8): /Library/Ruby/Gems/1.8
                 (2.3.5): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
                 (2.3.4): /Library/Ruby/Gems/1.8
                 (2.2.2): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
                 (1.2.6): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

    Web-application framework with template engine, control-flow layer,
    and ORM.

Now, here is where I am lost: in environment.rb I have this line to select rails 2.3.4.

RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION

If I change this line to:

RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

The error goes away. I know there are versions of rails installed in different locations, but the two versions in question are installed in the same location. Why would 2.3.8 not raise an error, while 2.3.4 does?

How can I resolve this issue?

NOTE: I am running on Passenger

ALSO, OF NOTE: script/console appears to work under 2.3.4... but the app still fails in a web browser.

UPDATE

Okay, so I checked the PassengerRuby directive in httpd.conf and it was /usr/local/bin/ruby while which ruby produced /usr/bin/ruby. I changed the directive to /usr/bin/ruby.

This solved the web browser issue, however now script/console is failing with the same error:

Missing the Rails 2.3.4 gem. Please gem install -v=2.3.4 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

So now, I can view the project fine in a web browser. But I cannot use any rails scripts, and rake db:migrate fails with the following error:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in report_activate_error': Could not find RubyGem rake (>= 0) (Gem::LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in activate' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem' from /usr/bin/rake:18


You might have the gems installed, but Passenger may be looking in a different location. One thing that might work is setting the GEM_HOME environment variable in your configuration.

In Apache this would look like:

SetEnv GEM_HOME /Library/Ruby/Gems/1.8

You may find that 2.3.4 isn't in that directory for some reason, like it was a failed install that doesn't contain any files.

Make sure that 2.3.4 is properly loaded by having a look:

% ls -l /Library/Ruby/Gems/1.8/gems/rails-2.3.4


Does the PassengerRuby directive in your Apache config match the output you get from "which ruby"? If not then your passenger isn't looking for gems in the same place you are

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜