Fix Bundler that re-exec $0 when a version is present in the config:
#9249
+84
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Bundler that re-exec $0 when a
versionis present in the config:Problem
If you have a
versionin your config file (this feature was introduced in #6817), then running anybundlecommand will make Bundler re-exec and ultimately run thebundlebinstub twice.Details
When the
bundlebinstub gets executed, arequire "bundler"is evaluated. RubyGems tries to require thebundler.rbfile from the rightbundlergem (in the event where you have multiple bundler versions in your system). RubyGems will prioritize a bundler version based on a few heurisitics.rubygems/lib/rubygems/bundler_version_finder.rb
Lines 19 to 21 in b50c40c
This prioritize logic doesn't take into account the bundler version a user has specified in its config. So what happens is:
bundlebinstubrequire 'bundler'is evaluated.Solution
This patch introduce two fixes. First, it reads the bundler config file and check for the local config and then the global config. This is because the local has precedence over global (see the order here.
Second, the prioritization takes into account the version in a user's config and let RubyGems activate the right version in order to prevent re-exec moments later.
Finally, I also want to fix this problem because its a step toward fixing #8106. I'll open a follow up patch to explain.
Make sure the following tasks are checked