Skip to content

Commit

Permalink
[rubygems/rubygems] Fix bundle outdated <GEM> failing if gems not i…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed Dec 26, 2024
1 parent d78ff6a commit 11c9e4f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/bundler/cli/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def initialize(options, gems)
def run
check_for_deployment_mode!

gems.each do |gem_name|
Bundler::CLI::Common.select_spec(gem_name)
end

Bundler.definition.validate_runtime!
current_specs = Bundler.ui.silence { Bundler.definition.resolve }

gems.each do |gem_name|
if current_specs[gem_name].empty?
raise GemNotFound, "Could not find gem '#{gem_name}'."
end
end

current_dependencies = Bundler.ui.silence do
Bundler.load.dependencies.map {|dep| [dep.name, dep] }.to_h
end
Expand Down
38 changes: 38 additions & 0 deletions spec/bundler/commands/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,44 @@ def test_group_option(group)

expect(out).to match(Regexp.new(expected_output))
end

it "does not require gems to be installed" do
build_repo4 do
build_gem "zeitwerk", "1.0.0"
build_gem "zeitwerk", "2.0.0"
end

gemfile <<-G
source "https://gem.repo4"
gem "zeitwerk"
G

lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
zeitwerk (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
zeitwerk
BUNDLED WITH
#{Bundler::VERSION}
L

bundle "outdated zeitwerk", raise_on_error: false

expected_output = <<~TABLE.tr(".", "\.").strip
Gem Current Latest Requested Groups
zeitwerk 1.0.0 2.0.0 >= 0 default
TABLE

expect(out).to match(Regexp.new(expected_output))
expect(err).to be_empty
end
end

describe "pre-release gems" do
Expand Down

0 comments on commit 11c9e4f

Please sign in to comment.