summaryrefslogtreecommitdiff
path: root/lib/bundler/self_manager.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-07-12 16:08:32 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-07-13 11:36:03 +0900
commitf16c880f776450771196c35cec10b9a5860a560f (patch)
tree0a5b3852cc1c53746ff97402891e37ae77d97bc8 /lib/bundler/self_manager.rb
parent8f61a4c5b2f26df3a487c1a77b24488b437e793c (diff)
[rubygems/rubygems] Introduce bundle config set version feature
https://github.com/rubygems/rubygems/commit/c431a1df52
Diffstat (limited to 'lib/bundler/self_manager.rb')
-rw-r--r--lib/bundler/self_manager.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 827f3f9222..70a5fedabd 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -15,11 +15,23 @@ module Bundler
def install_locked_bundler_and_restart_with_it_if_needed
return unless needs_switching?
- Bundler.ui.info \
- "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
- "Installing Bundler #{lockfile_version} and restarting using that version."
+ begin
+ # BUNDLE_VERSION=x.y.z
+ restart_version = Gem::Version.new(Bundler.settings[: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.ui.info \
+ "Bundler #{current_version} is running, but your lockfile was generated with #{restart_version}. " \
+ "Installing Bundler #{restart_version} and restarting using that version."
+ end
- install_and_restart_with(lockfile_version)
+ install_and_restart_with(restart_version)
end
def update_bundler_and_restart_with_it_if_needed(target)
@@ -79,7 +91,8 @@ module Bundler
autoswitching_applies? &&
released?(lockfile_version) &&
!running?(lockfile_version) &&
- !updating?
+ !updating? &&
+ Bundler.settings[:version] != "global"
end
def autoswitching_applies?