diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-08-21 20:13:03 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | c119dd2b5a0466ba317c2b5981c686355d7e3b6e (patch) | |
tree | 57d6247719891c06b3238e2b47bf9cab4bb42ddc | |
parent | c044f818ca47511dceefcdddba64e4f144e8c731 (diff) | |
download | ruby-c119dd2b5a0466ba317c2b5981c686355d7e3b6e.tar.gz |
[rubygems/rubygems] Fix `bundle plugin install` misdetection of installed versions
https://github.com/rubygems/rubygems/commit/9c88db949d
-rw-r--r-- | lib/bundler.rb | 16 | ||||
-rw-r--r-- | lib/bundler/plugin/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 2 | ||||
-rw-r--r-- | spec/bundler/plugins/install_spec.rb | 15 |
4 files changed, 26 insertions, 9 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index d646cb08ee..dcbc3fdfb7 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -636,6 +636,12 @@ EOF @rubygems = nil end + def configure_gem_home_and_path(path = bundle_path) + configure_gem_path + configure_gem_home(path) + Bundler.rubygems.clear_paths + end + private def eval_yaml_gemspec(path, contents) @@ -656,12 +662,6 @@ EOF raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents) end - def configure_gem_home_and_path - configure_gem_path - configure_gem_home - Bundler.rubygems.clear_paths - end - def configure_gem_path unless use_system_gems? # this needs to be empty string to cause @@ -671,8 +671,8 @@ EOF end end - def configure_gem_home - Bundler::SharedHelpers.set_env "GEM_HOME", bundle_path.to_s + def configure_gem_home(path) + Bundler::SharedHelpers.set_env "GEM_HOME", path.to_s end def tmp_home_path diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 54ce8528cf..d7411fff45 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -81,6 +81,8 @@ module Bundler deps = names.map {|name| Dependency.new name, version } + Bundler.configure_gem_home_and_path(Plugin.root) + definition = Definition.new(nil, deps, source_list, true) install_definition(definition) end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 167bea392f..7f8699b91c 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -144,7 +144,7 @@ module Bundler end end - if (installed?(spec) || Plugin.installed?(spec.name)) && !force + if installed?(spec) && !force print_using_message "Using #{version_message(spec)}" return nil # no post-install message end diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index b382d3ccd2..009516260a 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -69,6 +69,21 @@ RSpec.describe "bundler plugin install" do plugin_should_be_installed("foo", "kung-foo") end + it "installs the latest version if not installed" do + update_repo2 do + build_plugin "foo", "1.1" + end + + bundle "plugin install foo --version 1.0 --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Installing foo 1.0") + + bundle "plugin install foo --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Installing foo 1.1") + + bundle "plugin install foo --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Using foo 1.1") + end + it "works with different load paths" do build_repo2 do build_plugin "testing" do |s| |