ENV['GEM_PATH'] respected but not ENV['BUNDLE_PATH'] #875

hedgehog opened this Issue Nov 24, 2010 · 6 comments

4 participants


Some env variables are checked and respected, others not.

One that is not is BUNDLE_PATH. This can be set in the .bundle/config file, but not through and env variable.

Use case: On the fly override by setting ENV['BUNDLE_PATH'] in the Gemfile.


Just to clarify one side effect is the following:
If you set this in the Gemfile:


Then after bundle install you will see Bundler report:

Your bundle is complete! It was installed into /tmp/test


$ ls -la /tmp/test
total 8
drwxr-xr-x  2 hedge users    6 2010-11-23 21:26 .
drwxrwxrwt 50 root  root  4096 2010-11-24 15:51 ..

The bundle config is:

$ cat .bundle/config
Bundler member

Bundler respects the env var BUNDLE_PATH. It does not, however, work to change BUNDLE_PATH inside the Gemfile. By the time the Gemfile is evaluated, Bundler has already started up, read the environment, and determined the value of BUNDLE_PATH (if any). IIRC, the value of BUNDLE_PATH is used during the Gemfile eval, so it can't be changed in the middle.

As you correctly note, changing it inside the Gemfile changes the message that is printed out at the end of the install process -- that's a bug, and Bundler should probably error out if BUNDLE_PATH changes inside the Gemfile. No one's ever tried it before now, so it wasn't something we knew we needed to check for and guard against.


Okay does closed mean fixed? i.e.

changing it inside the Gemfile changes the message that is printed out at the end of the install process -- that's a bug


I've resolved this for Git sources by respecting ENV['BUNDLE_INSTALL_PATH'] in the Gemfile.
Pull request to come.

$ cat <<-EOT >Gemfile
source :rubygems
gem "apt",:git => "git://github.com/cookbooks/apt.git",:tag => 'qa-latest'

$ bundle
Fetching git://github.com/cookbooks/apt.git
remote: Counting objects: 198, done.
remote: Compressing objects: 100% (102/102), done.
remote: Total 198 (delta 80), reused 194 (delta 80)
Receiving objects: 100% (198/198), 31.26 KiB, done.
Resolving deltas: 100% (80/80), done.
Fetching source index for http://rubygems.org/
Using apt (0.9.3) from git://github.com/cookbooks/apt.git (at qa-latest) 
Using bundler (1.1.pre.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

$ bundle show apt

This is not fixed. But you should use custom path before bundler is loaded.

For example BUNDLE_PATH=/tmp/scratch bundle install. That works fine.

@ixti I think you can close this.

Bundler member

@simi agree.

@ixti ixti closed this Jul 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment