1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[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
This commit is contained in:
citrusmoose 2022-06-16 15:13:17 -04:00 committed by git
parent ec5c56412f
commit 8d689294d0
2 changed files with 9 additions and 2 deletions

View file

@ -29,7 +29,9 @@ module Bundler
@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
"#{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

View file

@ -202,8 +202,9 @@ RSpec.shared_examples "bundle install --standalone" do
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