Skip to content

Commit

Permalink
[rubygems/rubygems] Improve error message in frozen mode edge case
Browse files Browse the repository at this point in the history
When a top level dependency is missing from the lockfile, and we're in
frozen mode, we should also print a "frozen error".

rubygems/rubygems@3e82b835e3
  • Loading branch information
deivid-rodriguez authored and hsbt committed Jun 14, 2023
1 parent e86f4c5 commit 3e7f5b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/bundler/definition.rb
Expand Up @@ -677,10 +677,14 @@ def check_missing_lockfile_dep
if missing.any?
@locked_specs.delete(missing)

missing.first.name
else
false
return missing.first.name
end

return if @dependency_changes

current_dependencies.find do |d|
@locked_specs[d.name].empty?
end&.name
end

def converge_paths
Expand Down
34 changes: 34 additions & 0 deletions spec/bundler/install/deploy_spec.rb
Expand Up @@ -312,6 +312,40 @@
expect(last_command).to be_success
end

it "shows a good error if a gem is missing from the lockfile" do
build_repo4 do
build_gem "foo"
build_gem "bar"
end

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

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

bundle :install, :env => { "BUNDLE_FROZEN" => "true" }, :raise_on_error => false, :artifice => "compact_index"
expect(err).to include("Your lock file is missing \"bar\", but the lockfile can't be updated because frozen mode is set")
end

it "explodes if a path gem is missing" do
build_lib "path_gem"
install_gemfile <<-G
Expand Down

0 comments on commit 3e7f5b0

Please sign in to comment.