uninitialized constant ActiveSupport::Dependencies::Mutex

11 浏览
0 Comments

uninitialized constant ActiveSupport::Dependencies::Mutex

我试图将一个工作中的Rails项目从OSX迁移到Debian。在两个系统上我都使用了RVM,并为项目创建了相同的gemsets和rvmrc文件。在Debian上,我只安装了ruby,没有系统安装的ruby。\n当我进入项目文件夹时,RVM会切换到1.8.7版本,并使用项目的gemset,一切看起来都很正常。\n但是当我运行rake -T命令时,出现了以下错误:\n

$ rake -T --trace
(in /home/i/project/src)
rake aborted!
uninitialized constant ActiveSupport::Dependencies::Mutex
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:55
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/activesupport-2.3.5/lib/active_support.rb:56
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rails-2.3.5/lib/tasks/misc.rake:18
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rails-2.3.5/lib/tasks/rails.rb:4
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `each'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rails-2.3.5/lib/tasks/rails.rb:4
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/ws/project/src/Rakefile:10
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/    home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/gems/rake-0.8.7/bin/rake:31
/home/i/.rvm/gems/ruby-1.8.7-p249@project/bin/rake:19:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249@project/bin/rake:19

0
0 Comments

最近我自己也遇到了这个问题。如果你在谷歌上搜索一下,你会发现有几篇博客和邮件列表的帖子建议你在environment.rb中显式地require "threads"。然而,这对我并不起作用,但是降级rubygems可以解决这个问题:

sudo gem update --system 1.3.7

其中一些帖子还提到升级到Rails的新版本,但是在我们的情况下,这不是一个选项。

0
0 Comments

在Rails项目的根目录下的Rakefile文件的第一行添加require 'thread'这一行代码即可解决(uninitialized constant ActiveSupport::Dependencies::Mutex)的问题。

0
0 Comments

在我的情况下,添加require 'thread'也没有起作用。

问题是通过将rubygems降级到1.4.2版本来解决的:

这是一个较新版本的rubygems(在我的情况下是1.8.5)与旧版本的rails(在我的情况下是2.3.5)之间的兼容性问题。

$ gem install rubygems-update -v='1.4.2'

$ gem uninstall rubygems-update -v='1.8.5'

$ update_rubygems

0