[前][次][番号順一覧][スレッド一覧]

ruby-changes:67468

From: David <ko1@a...>
Date: Tue, 31 Aug 2021 19:07:42 +0900 (JST)
Subject: [ruby-changes:67468] c119dd2b5a (master): [rubygems/rubygems] Fix `bundle plugin install` misdetection of installed versions

https://git.ruby-lang.org/ruby.git/commit/?id=c119dd2b5a

From c119dd2b5a0466ba317c2b5981c686355d7e3b6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sat, 21 Aug 2021 20:13:03 +0200
Subject: [rubygems/rubygems] Fix `bundle plugin install` misdetection of
 installed versions

https://github.com/rubygems/rubygems/commit/9c88db949d
---
 lib/bundler.rb                       | 16 ++++++++--------
 lib/bundler/plugin/installer.rb      |  2 ++
 lib/bundler/source/rubygems.rb       |  2 +-
 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 d646cb0..dcbc3fd 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -636,6 +636,12 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L636
       @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 https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L662
       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 https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L671
       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 54ce852..d7411ff 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -81,6 +81,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/plugin/installer.rb#L81
 
         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 167bea3..7f8699b 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -144,7 +144,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L144
           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 b382d3c..0095162 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 https://github.com/ruby/ruby/blob/trunk/spec/bundler/plugins/install_spec.rb#L69
     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|
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]