Respect Gemfile bundler setting in Bundler.setup#4892
Conversation
fa89f82 to
d82662f
Compare
|
Hei @godfat, this is great! I was actually aware of this issue and I was trying a different approach at #3963 to fix it. The approach here is not as correct because it requires to "re-resolve" settings (that However, the So, I'm not fully sure, but I tend to think we should go with the approach in here first, and then consider #3963 later. |
|
@deivid-rodriguez Oh! I see where this was coming from now. Thank you for the context. The thing I was missing was that I didn't know the config path can actually be based on where I think this is problematic given how the configuration setting is designed right now. Like you mentioned, this is chicken-and-egg and it's impossible to be perfectly resolved if we keep it that way. I personally think that ideally the config path should be configurable via something like It seems like we can actually do that with I suppose that's also what you're trying to do with #3963, excuse me I didn't read through all the changes carefully. Bundler is so crucial to many projects, and given how complex it is right now, any compatibility related changes can cause huge issues. I'll be honest I wasn't really happy when bundler broke the setup from time to time, so I can fully understand that we should not introduce any breakage, and everything will have to be backward compatible. So perhaps my question is, can you foresee this pull request might introduce any incompatibility, even when it should be fixing some consistency issue? If no, I would highly hope this can be merged first, and would be nice to be back porting it as well. There's a failure: https://github.com/rubygems/rubygems/runs/3496250763 This was with |
When we run `bundle exec` it'll look at `Bundler.settings[:gemfile]` and respect the Gemfile setting. However, when we just require `bundler/setup` or run `Bundle.setup`, it'll not look through that. This should make this behaviour consistent. More details can be found at: https://gitlab.com/gitlab-org/gitlab/-/issues/339939#note_667461354
d82662f to
5e63331
Compare
The test was only checking that `bundle install` works with a custom gemfile, but the purpose of this PR is to make `Bundler.setup` respect the setting too. Updated the test to actually invoke Bundler.setup and verify it loads gems from the custom gemfile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When we run
bundle execit'll look atBundler.settings[:gemfile]and respect the Gemfile setting. However, when we just require
bundler/setupor runBundle.setup, it'll not look through that.This should make this behaviour consistent.
More details can be found at:
https://gitlab.com/gitlab-org/gitlab/-/issues/339939#note_667461354
What was the end-user or developer problem that led to this PR?
Try the following scenario:
bundler config set --local gemfile SomethingSomethingbut notGemfilebundle execwill look forSomethingas expected, butruby -rbundler/setupwill notWhat is your fix for the problem, implemented in this PR?
I found in
bundler/lib/bundler/cli.rbthere's a snippet:This does not run when we run
Bundler.setupcausing this inconsistency.In order to fix it, make sure we also run this in
Bundler.setup.Make sure the following tasks are checked