Skip to content

Commit

Permalink
with_original_env so BUNDLER_APP_CONFIG is honored
Browse files Browse the repository at this point in the history
Bundler's `with_clean_env` completely erases all Bundler-related
environment variables, even if those variables existed prior to loading
Bundler. That means that custom Bundler settings that we legitimately
want to pass down to child processes - namely, `BUNDLE_APP_CONFIG` - are
erased, leading to errors when the child process loads `bundler/setup`.

Note that `with_clean_env` is actually deprecated by Bundler. The method
recommended by Bundler going forward, and the one used in this commit,
is `with_original_env`. This clears any variables that were set by
Bundler itself, but retains any user-supplied settings that existed
prior.

This fixes a bug where spring binstubs would fail if `BUNDLE_APP_CONFIG`
was set to a custom location (i.e. other than the default `./.bundle`)
and `bundle install --path` was used. The binstub would not be able to
load the bundle because without `BUNDLE_APP_CONFIG`, it could not know
the path where the gems were installed.
  • Loading branch information
mattbrictson committed Nov 8, 2017
1 parent f0d2d65 commit b91fb94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@


* Fix binstubs not being replaced when their quoting style was changed (#534) * Fix binstubs not being replaced when their quoting style was changed (#534)
* Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true' * Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true'
* Fix binstub failures when Bundler's `BUNDLE_APP_CONFIG` environment variable is present (#545)


## 2.0.2 ## 2.0.2


Expand Down
2 changes: 1 addition & 1 deletion lib/spring/application_manager.rb
Expand Up @@ -92,7 +92,7 @@ def stop
def start_child(preload = false) def start_child(preload = false)
@child, child_socket = UNIXSocket.pair @child, child_socket = UNIXSocket.pair


Bundler.with_clean_env do Bundler.with_original_env do
@pid = Process.spawn( @pid = Process.spawn(
{ {
"RAILS_ENV" => app_env, "RAILS_ENV" => app_env,
Expand Down

0 comments on commit b91fb94

Please sign in to comment.