16

我有一个旧版本的 Rails 项目,它是在配置/环境文件中使用 BrowserCMS 构建的

RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION

所以我使用 rvm 安装了这个 gem,所以我可以运行它

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.8, 2.3.4)
actionpack (2.3.8, 2.3.4)
activerecord (2.3.8, 2.3.4)
activeresource (2.3.8, 2.3.4)
activesupport (2.3.8, 2.3.4)
bundler (1.1.4)
mysql (2.8.1)
rack (1.1.3, 1.0.1)
rails (2.3.4)
rake (0.8.7)

我运行 rake db:create它工作正常,但是当我运行时rake db:migrate出现此错误

rake aborted!
undefined method `name' for "actionmailer":String

我尝试使用 Trace 但没有任何帮助

$ rake db:migrate --trace
(in /home/azzurrio/Desktop/berkmancenter-fair_use_tool-f8f65ea)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `name' for "actionmailer":String
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/rails/gem_dependency.rb:268:in `=='
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:217:in `==='
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:217:in `matching_specs'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `find_all'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/specification.rb:411:in `each'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/specification.rb:410:in `each'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:216:in `find_all'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:216:in `matching_specs'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:238:in `to_specs'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems.rb:1210:in `gem'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/rails/gem_dependency.rb:73:in `add_load_paths'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:301:in `add_gem_load_paths'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:301:in `each'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:301:in `add_gem_load_paths'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:132:in `process'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
/home/azzurrio/Desktop/berkmancenter-fair_use_tool-f8f65ea/config/environment.rb:9
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rails-2.3.4/lib/tasks/misc.rake:4
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/share/ruby-rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/gems/rake-0.8.7/bin/rake:31
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/bin/rake:19:in `load'
/usr/share/ruby-rvm/gems/ruby-1.8.7-p358/bin/rake:19

请问有什么帮助吗?

4

2 回答 2

35

我有这个问题。解决方案是将 ruby​​gems 降级到您支持的版本。

我需要 1.3.5 版(用于 rails 2.3.5)

所以你需要这样做:

宝石安装 ruby​​gems-update -v 1.3.5

update_rubygems --version=1.3.5

现在 rake 应该可以工作了。

于 2012-10-01T12:45:32.820 回答
-1

我认为您应该更新 RubyGems 版本。
试试gem install rubygems-update

于 2012-06-14T09:05:32.843 回答