Assertfail

All Posts assertfail

View the Blog on GitHub wallymathieu

Bundler.with_clean_env

25 Jun 2014

Using ruby is kind of easy in the beginning. We started by having a folder of loose scripts. This turned a bit messy after a while. By moving these to separate gems we got some needed structure. Many of the programmers complained about globally installed gems (i.e. our local gems). In order to get a predictable executing environment we started to levarage bundler more and more. Turns out that there is a gotcha: Executing a bundle exec script inside a bundle exec script. The inside script will inherit the environment from the outer script. In order to avoid this you can use:

Bundler.with_clean_env do
    ...
end

This method is not documented, but it really should be (I’ll do it if I find time).

Tags

  • ruby
  • Comments or errors? Fork post and do a pull request on github