2

我在我的 Gemfile 中添加了 composite_primary_keys gem。在本地环境中它运行良好,但在 centos 机器上它因以下错误而中断。Ruby 版本是 1.9.2p290,rubygems 版本在两个环境中都是 1.3.7。有谁知道为什么会这样?

bundle exec rake db:create --trace

no such file to load -- active_record/associations/has_and_belongs_to_many_association
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/tmp/jenkins/gem_cache/myapp/gems/composite_primary_keys-4.1.2/lib/composite_primary_keys.rb:40:in `<top (required)>'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
/opt/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
4

3 回答 3

1

尝试将 Composite_primary_keys gem 与 A​​ctive Record 4.1.0 一起使用时,可能会发生相同的错误:

.../vendor/cache/ruby/1.9.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- active_record/associations/has_and_belongs_to_many_association (LoadError)
  from .../vendor/cache/ruby/1.9.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
  from .../vendor/cache/ruby/1.9.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
  ...

这是因为composite_primary_keys 的当前版本(截至2014 年4 月17 日的版本6.0.1)不包括对Active Record 4.1.0 的支持,这显然删除了有问题的文件。

但是,该问题已在gemar_4.1.x源代码分支中得到解决。如果您的项目使用 Bundler,解决方案是编辑其 Gemfile 并替换该行

gem 'composite_primary_keys'

gem 'composite_primary_keys', {
  :git => 'git://github.com/composite-primary-keys/composite_primary_keys.git',
  :branch => 'ar_4.1.x'
}

然后bundle install从项目的根文件夹运行。

于 2014-04-17T19:43:20.817 回答
0

更新您的 Gemfile: gem 'composite_primary_keys', '~> 7.0'

于 2014-09-06T19:40:59.920 回答
0

清理 jenkins 机器上的共享 gems 列表解决了这个问题。

于 2012-06-19T00:31:23.230 回答