0

在新的 Linux 安装上运行现有的 Rails 2.3.8 应用程序时,我遇到了一个有趣的问题。我已经安装了与运行它的服务器相同的所有 gem 版本。

首先,我不得不修改 Rakefile 以包含以下行,以停止有关未初始化常量 ActiveSupport::Dependencies::Mutex 的错误 -

require 'thread'

我认为这很不寻常,因为服务器上的 gem 版本与我在本地机器上安装的版本相匹配。当然,相同的代码应该功能相同。我觉得我一定遗漏了一些明显的东西。

无论如何,有了这个补丁我得到另一个错误:“未定义的方法名称”“RubyInline:String”

我找到了解决这个问题的解决方案,只需升级到 rails 2.3.12 - 我不热衷于这个想法,因为我想运行与生产服务器上相同版本的 rails 用于测试目的。我确实出于绝望尝试过,但它只是将错误推到了其他地方。

config/environment.rb:12 (以及一些后续行)

Rails::Initializer.run do |config|
  config.gem 'hobo'
  config.gem 'prawn'
  config.gem 'image_science'
  config.gem 'geokit'
  config.gem 'redis'

rake db:reset --trace 的输出

john@john-tosh:~/Work/source/AndroidServer2$ rake db:reset --trace
(in /home/graham/Work/source/AndroidServer2)
DEPRECATION WARNING: Rake tasks in vendor/plugins/open_flash_chart/tasks, vendor/plugins/prawnto/tasks, vendor/plugins/recaptcha/tasks, and vendor/plugins/ym4r_gm/tasks are deprecated. Use lib/tasks instead. (called from /var/lib/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:10)
** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:drop
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config 
** Execute db:create
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `name' for "RubyInline":String
/var/lib/gems/1.8/gems/rails-2.3.8/lib/rails/gem_dependency.rb:275:in `=='
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:217:in `==='
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:217:in `matching_specs'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `find_all'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:410:in `each'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:409:in `each'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:216:in `find_all'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:216:in `matching_specs'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:238:in `to_specs'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
/usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1208:in `gem'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/rails/gem_dependency.rb:73:in `add_load_paths'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:301:in `add_gem_load_paths'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:301:in `each'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:301:in `add_gem_load_paths'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:132:in `process'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
/home/graham/Work/source/AndroidServer2/config/environment.rb:12
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/var/lib/gems/1.8/gems/rails-2.3.8/lib/tasks/misc.rake:4
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' 
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/var/lib/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19
4

1 回答 1

0

此问题的解决方案是将 ruby​​gems(gem 命令)从已安装的版本降级到 1.3.5 - 与生产中安装的版本相同。

可能有更好的方法来做到这一点,但我使用了以下命令:

gem install -v 1.3.5 rubygems-update
ruby `gem env gemdir`/gems/rubygems-update-1.3.5/setup.rb

我希望这可以帮助那些发现自己处于这种令人沮丧的情况并最终通过谷歌来到这里的人。

我在这里找到了安装特定版本 ruby​​gems 的命令:将 ruby​​gems更新到 mac 上的特定版本

于 2012-08-10T23:07:19.997 回答