rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 2k forks source link

Can't fork() apps which use a different Gemfile #1166

Closed justindossey closed 13 years ago

justindossey commented 13 years ago

This is related to issue #739 with Unicorn, but I found it with a simple non-framework (no Rails, Sinatra, etc) application.

If you have two applications, call them "app1" and "app2", and they both have (different) Gemfiles, and you want to fork a process from app1 to run app2, you might do something like

  exec(RUBY, path_to_app2)
else
  Process.detach(pid)
end

However, app2 won't launch successfully if the Gemfile for app2 is not identical to that for app1. You can work around this by calling system() instead of exec(), but that is not a very good solution.

indirect commented 13 years ago

I think the "correct" way to work around this is by changing ENV before you exec.

justindossey commented 13 years ago

Indeed, adding ENV['BUNDLE_GEMFILE']=path_to_app2_gemfile makes the trouble go away, with the only ugliness that the caller must know the location to the file.

indirect commented 13 years ago

You can probably just delete BUNDLE_GEMFILE from ENV.

On May 12, 2011, at 4:05 PM, justindossey reply@reply.github.com wrote:

Indeed, adding ENV['BUNDLE_GEMFILE']=path_to_app2_gemfile makes the trouble go away, with the only ugliness that the caller must know the location to the file.

Reply to this email directly or view it on GitHub: https://github.com/carlhuda/bundler/issues/1166#comment_1149907