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

ruby-changes:72247

From: citrusmoose <ko1@a...>
Date: Mon, 20 Jun 2022 16:05:00 +0900 (JST)
Subject: [ruby-changes:72247] 8d689294d0 (master): [rubygems/rubygems] Fix extension paths in generated standalone script

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

From 8d689294d033d59f211a6d2c2da72b34ce53c4e5 Mon Sep 17 00:00:00 2001
From: citrusmoose <citrusmoose@u...>
Date: Thu, 16 Jun 2022 15:13:17 -0400
Subject: [rubygems/rubygems] Fix extension paths in generated standalone
 script

The paths for extensions of gems would contain the hardcoded ruby
version on which the extension was built. This will replace it with
runtime ruby version like the parent version directory. It will make the
standalone script compatible between different ruby version installations.

https://github.com/rubygems/rubygems/commit/a9dae93d5d
---
 lib/bundler/installer/standalone.rb          | 8 +++++++-
 spec/bundler/install/gems/standalone_spec.rb | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
index e8494b4bcd..2aba648e77 100644
--- a/lib/bundler/installer/standalone.rb
+++ b/lib/bundler/installer/standalone.rb
@@ -29,7 +29,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer/standalone.rb#L29
       @specs.map do |spec|
         next if spec.name == "bundler"
         Array(spec.require_paths).map do |path|
-          gem_path(path, spec).sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}')
+          gem_path(path, spec).
+            sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}').
+            sub(extensions_dir, 'extensions/\k<platform>/#{RbConfig::CONFIG["ruby_version"]}')
           # This is a static string intentionally. It's interpolated at a later time.
         end
       end.flatten.compact
@@ -39,6 +41,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer/standalone.rb#L41
       "#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}"
     end
 
+    def extensions_dir
+      %r{extensions/(?<platform>[^/]+)/#{RbConfig::CONFIG["ruby_version"]}}
+    end
+
     def bundler_path
       Bundler.root.join(Bundler.settings[:path], "bundler")
     end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index 0bbd829148..f856d6b51e 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -202,8 +202,9 @@ RSpec.shared_examples "bundle install --standalone" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gems/standalone_spec.rb#L202
     it "generates a bundle/bundler/setup.rb with the proper paths" do
       expected_path = bundled_app("bundle/bundler/setup.rb")
       extension_line = File.read(expected_path).each_line.find {|line| line.include? "/extensions/" }.strip
+      platform = Gem::Platform.local
       expect(extension_line).to start_with '$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/extensions/'
-      expect(extension_line).to end_with '/very_simple_binary-1.0")'
+      expect(extension_line).to end_with platform.to_s + '/#{RbConfig::CONFIG["ruby_version"]}/very_simple_binary-1.0")'
     end
   end
 
-- 
cgit v1.2.1


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

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