Skip to content

Instantly share code, notes, and snippets.

@rsutphin
Created April 19, 2012 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsutphin/2418518 to your computer and use it in GitHub Desktop.
Save rsutphin/2418518 to your computer and use it in GitHub Desktop.
Demonstrating an issue with Bundler.with_clean_env and local path installs (#1858)
.bundle
Gemfile.lock
local-bundle
# Actual gems are not important
source :rubygems
gem 'thor'
#!/bin/bash
rm -rf .bundle 'local-bundle'
bundle install --path 'local-bundle'
echo "Shell GEM_HOME (may be blank):"
env | grep GEM_HOME
echo "bundle exec GEM_HOME:"
bundle exec env | grep GEM_HOME
echo "with_original_env GEM_HOME:"
bundle exec ruby -e 'Bundler.with_original_env { system("env") }' | grep GEM_HOME
echo "with_clean_env GEM_HOME:"
bundle exec ruby -e 'Bundler.with_clean_env { system("env") }' | grep GEM_HOME
@rsutphin
Copy link
Author

When I run reproduce.sh with my system ruby on the path, I get this:

Fetching gem metadata from http://rubygems.org/..
Installing thor (0.14.6) 
Using bundler (1.1.3) 
Your bundle is complete! It was installed into ./local-bundle
Shell GEM_HOME (may be blank):
bundle exec GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.8
with_original_env GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.8
with_clean_env GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.8

If I run it with some rvm ruby selected, I get this:

Fetching gem metadata from http://rubygems.org/..
Installing thor (0.14.6) 
Using bundler (1.1.3) 
Your bundle is complete! It was installed into ./local-bundle
Shell GEM_HOME (may be blank):
GEM_HOME=/Users/rsutphin/.rvm/gems/ruby-1.9.3-p125
bundle exec GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.9.1
with_original_env GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.9.1
with_clean_env GEM_HOME:
GEM_HOME=/Users/rsutphin/tmp/clean_env/local-bundle/ruby/1.9.1

In both cases, the "original" and "clean" envs are tainted with the GEM_HOME set by bundler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment