开发者

Rails 3 error: no such file to load -- initializer (LoadError)

开发者 https://www.devze.com 2023-01-27 16:28 出处:网络
I\'m on Ubuntu and my app is written for Rails 2.3.5 and I got it to run on 2.3.10 but when I upgraded to Rails 3.0.3 and tried to run it using \"ruby script/server\", it throws this error.

I'm on Ubuntu and my app is written for Rails 2.3.5 and I got it to run on 2.3.10 but when I upgraded to Rails 3.0.3 and tried to run it using "ruby script/server", it throws this error.

/usr/local/lib/site_ruby/1.8/rubygems.rb:230:in `activate': can't activate rails (= 2.3.10, runtime) for [], already activated rails-3.0.3 for [] (Gem::LoadError)
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
        from /home/bob/savage/config/boot.rb:55:in `load_initializer'
        from /home/bob/savage/config/boot.rb:38:in `run'
        from /home/bob/savage/config/boot.rb:11:in `boot!'
        from /home/bob/savage/config/boot.rb:110
        from script/server:2:in `require'
        from script/server:2

When I uninstalled Rails 2.3.10, it throws this error instead

bob@ubuntu:~/test.2.3.10$ ruby script/server
/usr/local/lib/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': RubyGem version error: rails(3.0.3 not = 2.3.10) (Gem::LoadError)
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:211:in `activate'
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:1056:in `gem'
        from /home/bob/test.2.3.10/config/boot.rb:60:in `load_rails_gem'
        from /home/bob/test.2.3.10/config/boot.rb:54:in `load_initializer'
        from /home/bob/test.2.3.10/config/boot.rb:38:in `run'
        from /home/bob/test.2.3.10/config/boot.rb:11:in `boot!'
        from /home/bob/test.2.3.10/config/boot.rb:114
        from script/server:2:in `require'
        from sc开发者_StackOverflow中文版ript/server:2

Ideas? Thanks in advance for your help.


I was getting the same error until I realized that I was still using the same old config/boot.rb from the 2.3.10 version of my app. I went into a clean directory and generated a new Rails 3.0.3 app and used the boot.rb it created. The file is totally different, and it got me past this error.


I have the same problem.

After reading the comments above, I tried creating a new, empty application in another directory:
    rails new foo
    cd foo
    rails s

WEBrick starts up just fine. Perhaps Bob can duplicate this? This rules out problems with Rails and Ruby versions (3.0.3, 187p302 respectively for me). And it really points to problems with running Rails 3 utilities in directories with old versions of boot.rb or environment.rb, and running Rails 2 script files (plugin, server) once 3.0.3 is the active version of Rails.


This is the default Rails 3.0.0 config/boot.rb file. I would use all or parts of this instead of your config/boot.rb

require 'rubygems'

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])


Noticed 1.8 in your path - I believe you'll need to be on 1.9.2 for Rails 3 to work. Use RVM to get this up and running right away.

Additionally - you typically start Rails 3 with 'rails server' or 'rails s' - you don't need to fire off script/server anymore. Give that a go and see how it works.

0

精彩评论

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