【问题标题】:script/console won't work; reports "Missing the Rails gem. Please `gem install -v= rails`..." even though rails shows as installed脚本/控制台不起作用;报告“缺少 Rails gem。请 `gem install -v= rails`...”即使 rails 显示为已安装
【发布时间】:2010-06-21 02:02:49
【问题描述】:

我正在尝试学习 RoR,但运行脚本/控制台失败,返回:

加载开发环境(Rails 2.3.5) 缺少 Rails 宝石。请gem install -v= rails,更新 config/environment.rb 中的 RAILS_GEM_VERSION 设置为您已安装的 Rails 版本,或注释掉 RAILS_GEM_VERSION 以使用已安装的最新版本。

gem list 和 sudo gem list 均显示已安装的 rails (2.3.5)。此外,脚本/服务器工作正常。我发现一些消息来源表明问题可能出在机架 (1.1.0) 上,所以我恢复到 1.0.1,但没有帮助。

我很喜欢你们的任何建议,因为我真的很想学习 RoR,即使是到目前为止我所看到的简短内容。

编辑:@zed_0xff:

好的,这是./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

这是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

这有帮助吗?

编辑#2:@zed_0xff:

rake gems:

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

I = 已安装 F = 冷冻 R = 框架(在 rails 启动之前加载)`

config/environment.rb:

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

Rails::Initializer.run 做 |config| config.time_zone = 'UTC' 结束`

编辑#3:我修好了!听起来好像存在一些复杂的依赖问题。按照这里的建议:http://docs.heroku.com/rails236 升级到 rails 2.3.8 似乎已经解决了这个问题。 script/console 现在可以正常启动了。

【问题讨论】:

    标签: ruby-on-rails ruby rubygems


    【解决方案1】:

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

    【讨论】:

    • 它没有帮助。附上rake gems 输出和你的config/environment.rb
    猜你喜欢
    • 1970-01-01
    • 2013-11-30
    • 1970-01-01
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 2010-11-29
    • 2013-12-26
    相关资源
    最近更新 更多