-
Notifications
You must be signed in to change notification settings - Fork 345
Description
Summary
The BUNDLE_APP_CONFIG
environment variable, if set, tells bundler to use a different directory to store its config file (instead of the default ./.bundle
). Spring does not pass this variable to its child processes. Therefore when a Spring child process requires bundler/setup
, bundler does not look in the correct location for its config. This can lead to fatal errors when using spring binstubs.
Steps to reproduce
The bug can be reproduced by setting BUNDLE_APP_CONFIG
and installing gems using the --path
option.
We'll use Rails since it automatically sets up binstubs for us.
$ gem install rails -v 5.1.4
$ rails _5.1.4_ new binstub-error --no-rc
Setting BUNDLE_APP_CONFIG
and then installing the bundle into vendor/bundle
means that from hereon out bundler/setup
will only work properly if BUNDLE_APP_CONFIG
is honored.
$ mkdir -p /tmp/bundle-config-dir
$ export BUNDLE_APP_CONFIG=/tmp/bundle-config-dir
$ cd binstub-error
$ bundle install --path=vendor/bundle
Remove the system version of rake
so that the only way to get it is via vendor/bundle
:
$ gem uninstall rake --all
Notice that now the binstubs fails:
$ bin/rake --version
Could not find rake-12.2.1 in any of the sources
Run `bundle install` to install missing gems.
However bundle exec
works fine:
$ bundle exec rake --version
rake, version 12.2.1
If we put the bundler config in the default location and unset BUNDLE_APP_CONFIG
, the binstub now works:
$ cp -R $BUNDLE_APP_CONFIG .bundle
$ unset BUNDLE_APP_CONFIG
$ bin/rake --version
Running via Spring preloader in process 96969
rake, version 12.2.1
Workaround
Do not use BUNDLE_APP_CONFIG
.
Note that Circle CI sets the BUNDLE_APP_CONFIG
variable by default in its ruby:2.4.2-node-browsers
docker image, so many developers could run into this bug.