Skip to content

Commit

Permalink
[rubygems/rubygems] [rebuild_command] Bail early if the RubyGems vers…
Browse files Browse the repository at this point in the history
…ion doesn't match.

rubygems/rubygems@a691170dc7
  • Loading branch information
duckinator authored and matzbot committed Mar 29, 2024
1 parent 88d7be4 commit dfe83df
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/rubygems/commands/rebuild_command.rb
Expand Up @@ -83,6 +83,22 @@ def execute
download_gem(gem_name, gem_version, old_file)
end

rg_version = rubygems_version(old_file)
unless rg_version == Gem::VERSION
alert_error <<-EOF
You need to use the same RubyGems version #{gem_name} v#{gem_version} was built with.
#{gem_name} v#{gem_version} was built using RubyGems v#{rg_version}.
Gem files include the version of RubyGems used to build them.
This means in order to reproduce #{gem_filename}, you must also use RubyGems v#{rg_version}.
You're using RubyGems v#{Gem::VERSION}.
Please install RubyGems v#{rg_version} and try again.
EOF
terminate_interaction 1
end

source_date_epoch = get_timestamp(old_file).to_s

if build_path = options[:build_path]
Expand Down Expand Up @@ -247,4 +263,8 @@ def download_gem(gem_name, gem_version, old_file)

say "Downloaded #{gem_name} version #{gem_version} as #{old_file}."
end

def rubygems_version(gem_file)
Gem::Package.new(gem_file).spec.rubygems_version
end
end

0 comments on commit dfe83df

Please sign in to comment.