Always install the bundler gem in the system gems path:
#9252
+86
−27
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.
Always install the bundler gem in the system gems path
Fix #8106
Problem
Bundler autoswitch feature kicks in unexpectedly which ends up creating issue as described in #8106.
This patch solves this problem, but will also prevent Bundler from autoswitching most of the time, thanks to picking up the right bundler version from the start.
Details
When
bundle installis ran, Bundler reads the Gemfile.lock andcheck theBUNDLED WITHsection to see if the runtime bundler version matches. If not, Bundler install the version requested by the Gemfile.lock and put that newbundlergem inside theBUNDLE_PATHconfigured.Installing the
bundlergem inside theBUNDLE_PATHinstead of system gems is the main reason the Bundler autoswitch feature exists.In this patch, I propose that we always install
bundlerinside system gems.By doing this, when a call to
require 'bundler'is encountered, RubyGems will be able to detect allbundlerversion that exists on the user's machine and be able to pick the right bundler version, without doing this kernel exec gymnastic.Right now, if the bundler version specified in the Gemfile.lock is installed outside system gems, then RubyGems will activate the latest bundler version found in system gems, then, when bundler is loaded, Bundler autoswitch kicks in which modifies
GEM_HOME(with whatever the user configured inBUNDLE_PATH) and see that another bundler version matching the Gemfile.lock exists.It then re-exec with
Kernel.execand override theGEM_HOMEenv, so that when the script is reexecuted and therequire 'bundler'is encountered again, RubyGems will search for bundler in the correct folder.