Signal playing nice with Bundler

When Signal changed to Bundler as the gem dependency manager, all the projects inside it that were also using Bundler started to break, as some gems were not being loaded. This behavior did also occur with other continuous integration tools that also use Bundler, like Integrity.

This problem happend because when Bundler is loaded it sets some environment variables like BUNDLE_GEMFILE and this environment variables were being read by the projects inside Signal.

Let’s suppose Signal is installed in /var/local/apps/signal. When Signal is started, it will load Bundler and Bundler will try to read the environment variable BUNDLE_GEMFILE to know where the Gemfile is. As BUNDLE_GEMFILE is empty, it will read the Gemfile in the application root path and set this path to BUNDLE_GEMFILE. At this moment, the value of BUNDLE_GEMFILE is /var/local/apps/signal/Gemfile.

Now lets imagine we have a project inside Signal called Panthers and that his build script is like this:

bundle install
rake spec

When this script is executed by Signal, it will load Bundler and again Bundler will try to read the environment variable BUNDLE_GEMFILE to know where the Gemfile is. The problem is that at this time BUNDLE_GEMFILE would be set to /var/local/apps/signal/Gemfile and because of this Bundler will load Signal‘s gems instead of Panther’s gems.

To resolve this, now when Signal executes a build script, it unsets some environment variables like BUNDLE_GEMFILE and RAILS_ENV, trying to simulate a “clean” environment.

If you know a better solution for this, please let me know.