简体   繁体   中英

script/console won't work; reports “Missing the Rails gem. Please `gem install -v= rails`…” even though rails shows as installed

I'm trying to learn RoR, and running script/console fails, returning:

Loading development environment (Rails 2.3.5) Missing the Rails gem. Please gem install -v= 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.

Both gem list and sudo gem list show rails (2.3.5) as installed. Additionally, script/server works fine. I found some sources that suggested the problem might be with rack (1.1.0), so I reverted back to 1.0.1, but it didn't help.

I'd love any suggestions you guys have, because I really want to learn RoR after even the brief bits I've seen so far.

EDIT: @zed_0xff:

All right, here's the result of ./script/console --trace :

/usr/lib/ruby/1.8/optparse.rb:1450:in `complete': invalid option: --trace (OptionParser::InvalidOption)
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `complete'
    from /usr/lib/ruby/1.8/optparse.rb:1261:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1248:in `order!'
    from /usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'
    from /usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'
    from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/console.rb:11
    from /usr/lib/ruby/1.8/optparse.rb:791:in `initialize'
    from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/console.rb:6:in `new'
    from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/console.rb:6
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from ./script/console:3

And here's the result of rake db:migrate --trace :

(in /home/carpdiem/Dropbox/programming/ruby/rails_projects/demo_app)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment 
** Execute db:schema:dump

Does that help?

EDIT #2: @zed_0xff:

rake gems :

`(in /home/carpdiem/Dropbox/programming/ruby/rails_projects/demo_app)

I = Installed F = Frozen R = Framework (loaded before rails starts)`

config/environment.rb:

`require File.join(File.dirname( File ), 'boot')

Rails::Initializer.run do |config| config.time_zone = 'UTC' end`

EDIT #3: I fixed it! It sounds like there was some complicated dependency issues at fault. Following the suggestion from here: http://docs.heroku.com/rails236 to upgrade to rails 2.3.8 seems to have resolved the problem. script/console starts up correctly now.

尝试运行./script/console --tracerake db:migrate --trace ,rake命令也可能会失败,但是--trace开关可以为您的应用程序失败提供有价值的信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM