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

ruby-changes:72033

From: David <ko1@a...>
Date: Wed, 1 Jun 2022 17:07:47 +0900 (JST)
Subject: [ruby-changes:72033] 0a6b9924bd (master): [rubygems/rubygems] Fix generated standalone script for default gems

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

From 0a6b9924bd1b45bd8ad29b1eb3c8a65835f5864d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Mon, 30 May 2022 21:48:49 +0200
Subject: [rubygems/rubygems] Fix generated standalone script for default gems

The installer is actually rewriting the spec's full gem path to be the
one of the newly installed gem, however the accessor was not properly
working for `StubSpecification` instances, and default gems are always
of this type, because they are always present locally.

Fix the accessor to properly update the underlying full specification.

https://github.com/rubygems/rubygems/commit/efa41babfa
---
 lib/bundler/stub_specification.rb            | 4 ++++
 spec/bundler/install/gems/standalone_spec.rb | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index 4a23b2cfe8..88a4257fa4 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -67,6 +67,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/stub_specification.rb#L67
       stub.full_gem_path
     end
 
+    def full_gem_path=(path)
+      stub.full_gem_path = path
+    end
+
     def full_require_paths
       stub.full_require_paths
     end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index 5cbb484c68..0bbd829148 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -147,9 +147,16 @@ RSpec.shared_examples "bundle install --standalone" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gems/standalone_spec.rb#L147
       bundle "lock", :dir => cwd, :artifice => "compact_index"
     end
 
-    it "works" do
+    it "works and points to the vendored copies, not to the default copies" do
       bundle "config set --local path #{bundled_app("bundle")}"
       bundle :install, :standalone => true, :dir => cwd, :artifice => "compact_index", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
+
+      load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }
+
+      expect(load_path_lines).to eq [
+        '$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/bar-1.0.0/lib")',
+        '$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/foo-1.0.0/lib")',
+      ]
     end
   end
 
-- 
cgit v1.2.1


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

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