summaryrefslogtreecommitdiff
path: root/lib/bundler/self_manager.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-07-12 16:29:48 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-07-13 11:36:03 +0900
commitd3305cab44ff6c9e59778c0737d8426fe8563ae8 (patch)
treef87aad94f90a645b68ae109c280bcbc4d87ef57c /lib/bundler/self_manager.rb
parentf16c880f776450771196c35cec10b9a5860a560f (diff)
[rubygems/rubygems] restart with BUNDLE_VERSION if it's specified
https://github.com/rubygems/rubygems/commit/57cfe7cf8d
Diffstat (limited to 'lib/bundler/self_manager.rb')
-rw-r--r--lib/bundler/self_manager.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 70a5fedabd..491800514d 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -9,25 +9,19 @@ module Bundler
def restart_with_locked_bundler_if_needed
return unless needs_switching? && installed?
- restart_with(lockfile_version)
+ restart_with(restart_version)
end
def install_locked_bundler_and_restart_with_it_if_needed
return unless needs_switching?
- begin
- # BUNDLE_VERSION=x.y.z
- restart_version = Gem::Version.new(Bundler.settings[:version])
-
+ if restart_version == lockfile_version
Bundler.ui.info \
- "Bundler #{current_version} is running, but your configuration was #{restart_version}. " \
- "Installing Bundler #{restart_version} and restarting using that version."
- rescue ArgumentError
- # BUNDLE_VERSION=local
- restart_version = lockfile_version
-
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
+ "Installing Bundler #{lockfile_version} and restarting using that version."
+ else
Bundler.ui.info \
- "Bundler #{current_version} is running, but your lockfile was generated with #{restart_version}. " \
+ "Bundler #{current_version} is running, but your configuration was #{restart_version}. " \
"Installing Bundler #{restart_version} and restarting using that version."
end
@@ -164,7 +158,7 @@ module Bundler
def installed?
Bundler.configure
- Bundler.rubygems.find_bundler(lockfile_version.to_s)
+ Bundler.rubygems.find_bundler(restart_version.to_s)
end
def current_version
@@ -177,5 +171,14 @@ module Bundler
parsed_version = Bundler::LockfileParser.bundled_with
@lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
end
+
+ def restart_version
+ return @restart_version if defined?(@restart_version)
+ # BUNDLE_VERSION=x.y.z
+ @restart_version = Gem::Version.new(Bundler.settings[:version])
+ rescue ArgumentError
+ # BUNDLE_VERSION=local
+ @restart_version = lockfile_version
+ end
end
end