[rubygems/rubygems] Auto switch to locked bundler version even when using binstubs
https://github.com/rubygems/rubygems/commit/076aba8b1c
This commit is contained in:
parent
ad9fe6f376
commit
3e84da0970
@ -167,6 +167,10 @@ module Bundler
|
||||
end
|
||||
end
|
||||
|
||||
def auto_switch
|
||||
self_manager.restart_with_locked_bundler_if_needed
|
||||
end
|
||||
|
||||
# Automatically install dependencies if Bundler.settings[:auto_install] exists.
|
||||
# This is set through config cmd `bundle config set --global auto_install 1`.
|
||||
#
|
||||
|
@ -65,7 +65,7 @@ module Bundler
|
||||
Bundler.reset_settings_and_root!
|
||||
end
|
||||
|
||||
Bundler.self_manager.restart_with_locked_bundler_if_needed
|
||||
Bundler.auto_switch
|
||||
|
||||
Bundler.settings.set_command_option_if_given :retry, options[:retry]
|
||||
|
||||
|
@ -92,6 +92,7 @@ module Bundler
|
||||
def autoswitching_applies?
|
||||
ENV["BUNDLER_VERSION"].nil? &&
|
||||
Bundler.rubygems.supports_bundler_trampolining? &&
|
||||
ruby_can_restart_with_same_arguments? &&
|
||||
SharedHelpers.in_bundle? &&
|
||||
lockfile_version
|
||||
end
|
||||
@ -151,6 +152,10 @@ module Bundler
|
||||
!version.to_s.end_with?(".dev")
|
||||
end
|
||||
|
||||
def ruby_can_restart_with_same_arguments?
|
||||
$PROGRAM_NAME != "-e"
|
||||
end
|
||||
|
||||
def updating?
|
||||
"update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
|
||||
end
|
||||
|
@ -5,6 +5,9 @@ require_relative "shared_helpers"
|
||||
if Bundler::SharedHelpers.in_bundle?
|
||||
require_relative "../bundler"
|
||||
|
||||
# autoswitch to locked Bundler version if available
|
||||
Bundler.auto_switch
|
||||
|
||||
# try to auto_install first before we get to the `Bundler.ui.silence`, so user knows what is happening
|
||||
Bundler.auto_install
|
||||
|
||||
|
@ -35,6 +35,17 @@ RSpec.describe "Self management", rubygems: ">= 3.3.0.dev", realworld: true do
|
||||
bundle "-v", artifice: nil
|
||||
expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
|
||||
|
||||
# App now uses locked version, even when not using the CLI directly
|
||||
file = bundled_app("bin/bundle_version.rb")
|
||||
create_file file, <<-RUBY
|
||||
#!#{Gem.ruby}
|
||||
require 'bundler/setup'
|
||||
puts Bundler::VERSION
|
||||
RUBY
|
||||
file.chmod(0o777)
|
||||
sys_exec "bin/bundle_version.rb", artifice: nil
|
||||
expect(out).to eq(previous_minor)
|
||||
|
||||
# Subsequent installs use the locked version without reinstalling
|
||||
bundle "install --verbose", artifice: nil
|
||||
expect(out).to include("Using bundler #{previous_minor}")
|
||||
@ -57,6 +68,17 @@ RSpec.describe "Self management", rubygems: ">= 3.3.0.dev", realworld: true do
|
||||
bundle "-v"
|
||||
expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
|
||||
|
||||
# App now uses locked version, even when not using the CLI directly
|
||||
file = bundled_app("bin/bundle_version.rb")
|
||||
create_file file, <<-RUBY
|
||||
#!#{Gem.ruby}
|
||||
require 'bundler/setup'
|
||||
puts Bundler::VERSION
|
||||
RUBY
|
||||
file.chmod(0o777)
|
||||
sys_exec "bin/bundle_version.rb", artifice: nil
|
||||
expect(out).to eq(previous_minor)
|
||||
|
||||
# Subsequent installs use the locked version without reinstalling
|
||||
bundle "install --verbose"
|
||||
expect(out).to include("Using bundler #{previous_minor}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user