How to get mongrel working with bundler?

时光怂恿深爱的人放手 提交于 2019-12-11 08:18:11

问题


Transitioning to bundler with an existing production setup. Naively with a gemfile and setup like:

gem "rails", "2.3.8"
gem "mongrel", git: "http://github.com/dynamix/mongrel.git"

bundle install --path /mnt/app/shared/bundle

Starting with

bundle exec mongrel_rails start --environment=production ...

results in

/mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require': 
no such file to load -- /mnt/services/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1/lib/mongrel/init.rb (MissingSourceFile)

What to do?


回答1:


To answer my own, since I couldn't find a correct solution elsewhere on the web for this scenario:

The problem seems to be an interaction of bundler and mongrel's use of the gem_plugin. Yes, these may be on life support but unfortunately lots of people's production configs still depend on them.

Seems that with mongrel --pre installed from the git source, it's looking in bundle/ruby/1.9.1/gems/mongrel_ instead of bundle/ruby/1.9.1/bundler/gems/mongrel_ which is where bundler is stashing the gem cloned from git.

So the solution that worked for our config is to just symlink them:

ln -s /mnt/app/shared/bundle/ruby/1.9.1/bundle/gems/mongrel* \
 /mnt/app/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1

This is clearly something simple that bundler could do automatically. Full trace of the exception was:

/mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require':
 no such file to load -- /mnt/app/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1/lib/mongrel/init.rb (MissingSourceFile)
    from /mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require'
    from /mnt/app/shared/bundle/ruby/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:134:in `block in load'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:241:in `each'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:241:in `each'
    from /mnt/services/shared/bundle/ruby/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load'
    from /mnt/app/shared/bundle/ruby/1.9.1/bundler/gems/mongrel-f3e69eb8e6fb/lib/mongrel/configurator.rb:231:in `load_plugins'


来源:https://stackoverflow.com/questions/3877967/how-to-get-mongrel-working-with-bundler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!