2012-06-13 57 views
2

我在我的Gemfile中添加了composite_primary_keys gem。在本地環境運行良好,但在一臺centos機器上,它會因以下錯誤而中斷。在兩種環境中,Ruby版本是1.9.2p290和rubygems版本是1.3.7。有誰知道爲什麼會這樣?沒有這樣的文件加載active_record/associations/has_and_belongs_to_many_association

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' 
+1

您可以加入鏈接到你的Gemfile和Gemfile.lock的的要旨? –

+1

您是否可以將捆綁列表輸入到兩種環境中。也嘗試做捆綁清理,然後捆綁安裝在遠程。 –

+0

謝謝拉爾斯。 [Gemfile](https://gist.github.com/2926554)和[Gemfile.lock](https://gist.github.com/2926555) –

回答

0

清理jenkins機器上的共享gems列表解決了問題。嘗試使用composite_primary_keys寶石與活動記錄4.1.0時,可能發生

1

同樣的錯誤:

.../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的(版本6.0.1截至2014年4月17日)的當前版本沒有按不包括對Active Record 4.1.0的支持,它顯然刪除了有問題的文件。

但是,該問題在the ar_4.1.x branch of the gem's source code中得到修復。如果你的項目使用捆紮機,一個解決方法是編輯Gemfile中它與

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

然後運行bundle install從項目的根文件夾替換線

gem 'composite_primary_keys' 

+0

謝謝你指出我朝着正確的方向。該分支目前不支持4.1最終版,但我相信它很快就會發布。 – 2014-04-18 18:19:58

+0

@Tricon:是的,我剛剛意識到,今天對4.1的支持只是初步的。因此,如果可能的話,也許最直接的解決方案是降級到Active Record 4.0。 –

0

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

+0

你的推理是什麼? – phs

相關問題