-
Notifications
You must be signed in to change notification settings - Fork 345
Use Bundler.with_original_env so that BUNDLER_APP_CONFIG is honored #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
(@rails-bot has picked a reviewer for you, use r? to override) |
Our builds were failing at the test suite stage in Circle CI because the We updated our Gemfile to use this branch for Thanks! The error we received was:
|
@rafaelfranca in your opinion is this fix worth pursuing? It seems that at least a handful of other people have found that this branch fixes their problems using spring binstubs on CircleCI. I can spend some more time on this PR to try and fix the Travis failures, but first I want to make sure it has a good chance of being accepted. Thanks! |
The same problem to me, CircleCI 2.0. I must disable spring on CI :( https://github.com/rails/spring#temporarily-disabling-spring |
@mattbrictson Do you know what introduced that problem? We haven't experienced this problem about a month ago, but now it's a common problem for local and Docker environment |
This code also updates spring and bundler. The spring issue is caused by a bug in spring, reported here: rails/spring#545 rails/spring#339 With a suggested fix here: rails/spring#546 However the fix is failing the spring travis tests. The work around in this commit manually sets the the ENV variable in ~/.spring.rb
I have the same issue in a Docker environment. Updating bundler to I'm not sure how this change would impact other projects, however. As a side note, we don't have the EDIT: my rubygems version is |
More information here rails#546
More information here rails#546
Confirmed that I am experiencing the same underlying problem and that this change fixes it. What's the likelihood of something like this making it into a new release? I guess I'm not sure I fully understand the benefits of |
As a temporary solution, we set Not actually related, but could be useful. Our part of Dockerfile ENV GEM_HOME /bundle
ENV BUNDLE_PATH=$GEM_HOME \
BUNDLE_APP_CONFIG=$BUNDLE_PATH \
BUNDLE_BIN=$BUNDLE_PATH/bin
ENV PATH /app/bin:$BUNDLE_BIN:$PATH |
Thanks for that explanation. Assuming this is all true, what's holding up this PR from being applied? Where is help needed to move this forward? I have some incentive and willingness to help here where I can. |
What are the version/dependency implications of this change / when did Bundler introduce Is it safe to just switch outright, or might there be a need to support both methods? |
@matthewd |
Here is the proof from Bundler's source code |
@matthewd Any chance we might see some progress on this issue? Where do you need help to move this forward. I'm willing to help if needed. |
Interested in seeing this fixed too! 👍 Using @mattbrictson's fix branch for Spring ( |
Facing the same issue in GitLab CI as well. Since I'm just starting out with my app and don't have a ton of tests, I'm disabling spring till this gets fixed.
|
I wasted my morning trying to figure out why Can we merge this one-line change that's been open for half a year? It's especially bad because it's in the default Gemfile for new rails projects, and the error is pretty difficult to track down. |
Thank you, @matthewd!! Will there be a new versioned release soon, or should we plan to work against the master branch for the near term? |
I'd like to get master's CI properly green before we cut a release. For this change: I'm happy that only Bundler >= 1.0 < 1.1 had |
Just wanted to mention that I needed to resort to using the
|
@Welkie The fix was merged, but no new version of Spring was released. I confirmed the fix works for me by using Thanks to anyone involved in fixing this! 👏 |
@davidstosik Awesome. I've been out of the loop with Rails for like 2 years but I wanted to update a project's dependencies and throw it on CircleCI. So this threw me off. Just wanted to comment so if anyone else comes here from googling, they know a fix is still needed. @literally_everyone Ty for the fix. :) |
FYI: Part of binstub ( if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
end Workaround not to stop using bin/spring: Replace contents of bin/spring with below snippet. #!/bin/bash
exec bundle exec spring "$@" |
Is there ETA to release this? I got the same issue in another project 😢 |
@matthewd I recognize and appreciate that you're waiting to get spring/lib/spring/client/binstub.rb Lines 39 to 41 in 6f1203a
|
Can we please release this? |
Today I faced to this issue, again. |
Please mention me if there is any blocker for release and perhaps I can help solving it. |
The CI is very broken so we can't release in that way. This PR may be the cause why it is broken. |
@rafaelfranca The build in the master branch has been green multiple times after this PR was merged. And it was red multiple times before this PR was merged. |
Yes, I confirmed this PR is not the cause |
If it is not, is there any chance we get a release soon? 🤞 |
@rafaelfranca Do you have a plan to release a new gem? I think that this fix is also related to rubygems/bundler#7184. If need to fix CI, I will do it. |
|
Since no one mentioned it explicitly in this thread, I'll note that |
Fixes #545.
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 loadsbundler/setup
.Note that
clean_env
(used bywith_clean_env
) is actually deprecated by Bundler. The method recommended by Bundler going forward, and the one used in this commit, iswith_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
) andbundle install --path
was used. The binstub would not be able to load the bundle because withoutBUNDLE_APP_CONFIG
, it could not know the path where the gems were installed.