Always install the bundler gem in the system gems path:#9252
Open
Edouard-chin wants to merge 1 commit intoruby:masterfrom
Open
Always install the bundler gem in the system gems path:#9252Edouard-chin wants to merge 1 commit intoruby:masterfrom
bundler gem in the system gems path:#9252Edouard-chin wants to merge 1 commit intoruby:masterfrom
Conversation
- Fix ruby#8106 - ### Problem Bundler autoswitch feature kicks in unexpectedly which ends up creating issue as described in ruby#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 install` is ran, Bundler reads the Gemfile.lock and check the `BUNDLED WITH` section to see if the runtime bundler version matches. If not, Bundler install the version requested by the Gemfile.lock and put that new `bundler` gem inside the `BUNDLE_PATH` configured. Installing the `bundler` gem inside the `BUNDLE_PATH` instead of system gems is the main reason the Bundler autoswitch feature exists. In this patch, I propose that we always install `bundler` inside system gems. By doing this, when a call to `require 'bundler'` is encountered, RubyGems will be able to detect *all* `bundler` version 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 in `BUNDLE_PATH`) and see that another bundler version matching the Gemfile.lock exists. It then re-exec with `Kernel.exec` and override the `GEM_HOME` env, so that when the script is reexecuted and the `require 'bundler'` is encountered again, RubyGems will search for bundler in the correct folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.