carlhuda/bundler — Issue #1677: Need a way to force bundle exec to reset environment
Author: primerano
Created: 2012-02-24 19:04:36+00:00
State: open

I have some rails applications that run rake tasks for other rails applications

here's an example

The following command is run from rails application A

command = "cd /application_b_path && bundle exec rake some_task --trace"
Kernel.system(command)

This command fails because bundle exec uses application A's Gems.

To work around this I do unnatural things like this

command = "cd /application_b_path && PATH=/usr/bin && unset BUNDLE_GEMFILE && bundle exec rake some_task --trace"

I need to clear the PATH because it contains gems specific to application A and I need to clear the BUNDLE_GEMFILE so it will use the one in /application_b_path

I have run into this 3 times already but there must be an easier way.

Thanks in advance for any pointers, suggestions or new features.