[rubygems/rubygems] Fix installing from source when same bundler version already a default gem

https://github.com/rubygems/rubygems/commit/620119308e
This commit is contained in:
David Rodríguez 2023-12-11 17:28:10 +01:00 committed by Hiroshi SHIBATA
parent 23289ad45b
commit c032dfb5cb
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -373,12 +373,12 @@ By default, this RubyGems will install gem as:
target_specs_dir target_specs_dir
end end
bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") } new_bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
full_name = bundler_spec.full_name full_name = new_bundler_spec.full_name
gemspec_path = "#{full_name}.gemspec" gemspec_path = "#{full_name}.gemspec"
default_spec_path = File.join(specs_dir, gemspec_path) default_spec_path = File.join(specs_dir, gemspec_path)
Gem.write_binary(default_spec_path, bundler_spec.to_ruby) Gem.write_binary(default_spec_path, new_bundler_spec.to_ruby)
bundler_spec = Gem::Specification.load(default_spec_path) bundler_spec = Gem::Specification.load(default_spec_path)
@ -395,16 +395,16 @@ By default, this RubyGems will install gem as:
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end end
bundler_bin_dir = bundler_spec.bin_dir bundler_bin_dir = new_bundler_spec.bin_dir
mkdir_p bundler_bin_dir, mode: 0o755 mkdir_p bundler_bin_dir, mode: 0o755
bundler_spec.executables.each do |e| bundler_spec.executables.each do |e|
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e) cp File.join("bundler", new_bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
end end
require_relative "../installer" require_relative "../installer"
Dir.chdir("bundler") do Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec) built_gem = Gem::Package.build(new_bundler_spec)
begin begin
Gem::Installer.at( Gem::Installer.at(
built_gem, built_gem,
@ -421,9 +421,9 @@ By default, this RubyGems will install gem as:
end end
end end
bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) } new_bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
say "Bundler #{bundler_spec.version} installed" say "Bundler #{new_bundler_spec.version} installed"
end end
def make_destination_dirs def make_destination_dirs