Skip to content

Commit

Permalink
[rubygems/rubygems] Fix installing from source when same bundler vers…
Browse files Browse the repository at this point in the history
…ion already a default gem

rubygems/rubygems@620119308e
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 12, 2023
1 parent 23289ad commit c032dfb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/rubygems/commands/setup_command.rb
Expand Up @@ -373,12 +373,12 @@ def install_default_bundler_gem(bin_dir)
target_specs_dir
end

bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
full_name = bundler_spec.full_name
new_bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
full_name = new_bundler_spec.full_name
gemspec_path = "#{full_name}.gemspec"

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)

Expand All @@ -395,16 +395,16 @@ def install_default_bundler_gem(bin_dir)
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end

bundler_bin_dir = bundler_spec.bin_dir
bundler_bin_dir = new_bundler_spec.bin_dir
mkdir_p bundler_bin_dir, mode: 0o755
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

require_relative "../installer"

Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec)
built_gem = Gem::Package.build(new_bundler_spec)
begin
Gem::Installer.at(
built_gem,
Expand All @@ -421,9 +421,9 @@ def install_default_bundler_gem(bin_dir)
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

def make_destination_dirs
Expand Down

0 comments on commit c032dfb

Please sign in to comment.