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.

4 Comments »

  1. Bundler provides its own mechanism to execute code in a clean environment: Bundler.with_clean_env. You can use it like this:

    Bundler.with_clean_env do
    system(”bundle install”)
    end

    Comment by Andre Arko — October 13, 2010 @ 7:29 pm
  2. Nice to know this Andre, I think the build can be executed inside this clean environment.

    Thanks for the tip :)

    Comment by Diego Carrion — October 13, 2010 @ 8:29 pm
  3. The subsequent time I learn a weblog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my option to learn, however I really thought youd have something interesting to say. All I hear is a bunch of whining about something that you would repair if you werent too busy looking for attention.

    Comment by Maynard Maury — April 12, 2011 @ 9:11 am
  4. It was nice to read your post. Thank you for posting this piece!

    Comment by edible arrangements coupon code — November 10, 2011 @ 7:08 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 Diego Carrion | powered by WordPress with Barecity