Skip to content

Commit 11c9e4f

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix bundle outdated <GEM> failing if gems not installed
rubygems/rubygems@694d5f444e
1 parent d78ff6a commit 11c9e4f

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

lib/bundler/cli/outdated.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ def initialize(options, gems)
2626
def run
2727
check_for_deployment_mode!
2828

29-
gems.each do |gem_name|
30-
Bundler::CLI::Common.select_spec(gem_name)
31-
end
32-
3329
Bundler.definition.validate_runtime!
3430
current_specs = Bundler.ui.silence { Bundler.definition.resolve }
3531

32+
gems.each do |gem_name|
33+
if current_specs[gem_name].empty?
34+
raise GemNotFound, "Could not find gem '#{gem_name}'."
35+
end
36+
end
37+
3638
current_dependencies = Bundler.ui.silence do
3739
Bundler.load.dependencies.map {|dep| [dep.name, dep] }.to_h
3840
end

spec/bundler/commands/outdated_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,44 @@ def test_group_option(group)
526526

527527
expect(out).to match(Regexp.new(expected_output))
528528
end
529+
530+
it "does not require gems to be installed" do
531+
build_repo4 do
532+
build_gem "zeitwerk", "1.0.0"
533+
build_gem "zeitwerk", "2.0.0"
534+
end
535+
536+
gemfile <<-G
537+
source "https://gem.repo4"
538+
gem "zeitwerk"
539+
G
540+
541+
lockfile <<~L
542+
GEM
543+
remote: https://gem.repo4/
544+
specs:
545+
zeitwerk (1.0.0)
546+
547+
PLATFORMS
548+
#{lockfile_platforms}
549+
550+
DEPENDENCIES
551+
zeitwerk
552+
553+
BUNDLED WITH
554+
#{Bundler::VERSION}
555+
L
556+
557+
bundle "outdated zeitwerk", raise_on_error: false
558+
559+
expected_output = <<~TABLE.tr(".", "\.").strip
560+
Gem Current Latest Requested Groups
561+
zeitwerk 1.0.0 2.0.0 >= 0 default
562+
TABLE
563+
564+
expect(out).to match(Regexp.new(expected_output))
565+
expect(err).to be_empty
566+
end
529567
end
530568

531569
describe "pre-release gems" do

0 commit comments

Comments
 (0)