Skip to content

Include detailed dependencies when gemfile and lockfile are conflicts#9332

Merged
hsbt merged 3 commits intomasterfrom
show-incorrect-dependencies-message
Mar 25, 2026
Merged

Include detailed dependencies when gemfile and lockfile are conflicts#9332
hsbt merged 3 commits intomasterfrom
show-incorrect-dependencies-message

Conversation

@hsbt
Copy link
Copy Markdown
Member

@hsbt hsbt commented Feb 13, 2026

What was the end-user or developer problem that led to this PR?

When dependabot or people changed constraint of lockfile, bundle install shows only parent gem name and version now.

I enhanced the error message to clearly display differences between gemspec and lockfile dependencies when they don't match.

What is your fix for the problem, implemented in this PR?

Before

Bundler found incorrect dependencies in the lockfile for rubocop-1.82.0
Please run bundle install to regenerate the lockfile.

After

Bundler found incorrect dependencies in the lockfile for rubocop-1.82.0

The gemspec for rubocop-1.82.0 specifies the following dependencies:
json (>= 2.3, < 4.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)

However, the lockfile has the following dependencies recorded:
json (>= 2.3, < 3.0)
parallel (~> 1.10)
parser (>= 3.2.0.0)

This discrepancy may be caused by manually editing the lockfile.
Please run bundle install to regenerate the lockfile with correct dependencies.

We easily find json and parser is conflict with rubocop update.

/cc @r7kamura

Make sure the following tasks are checked

Copilot AI review requested due to automatic review settings February 13, 2026 06:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the error message displayed when Bundler detects a mismatch between dependencies specified in a gemspec and those recorded in the lockfile. Instead of showing only the gem name and version, the error now displays detailed information about which dependencies differ between the gemspec and lockfile.

Changes:

  • Enhanced IncorrectLockfileDependencies error class to accept and display detailed dependency information
  • Updated the error instantiation in lazy_specification.rb to pass dependency details
  • Added comprehensive unit tests for the error class covering all scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
bundler/lib/bundler/errors.rb Enhanced IncorrectLockfileDependencies to display detailed dependency differences when available
bundler/lib/bundler/lazy_specification.rb Updated error instantiation to pass actual and lockfile dependencies
bundler/spec/bundler/errors_spec.rb Added comprehensive unit tests for the enhanced error message
bundler/spec/install/failure_spec.rb Added integration test to verify the detailed error message behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bundler/lib/bundler/errors.rb Outdated
Comment thread bundler/lib/bundler/errors.rb Outdated
hsbt and others added 3 commits March 25, 2026 15:20
When the lockfile dependencies don't match the gemspec, display both
sets of dependencies so users can easily identify which ones differ.
Instead of listing all dependencies from both gemspec and lockfile,
show only the ones that actually differ to make it easier to identify
the source of the discrepancy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hsbt hsbt force-pushed the show-incorrect-dependencies-message branch from f588fb6 to 7c30560 Compare March 25, 2026 06:25
@hsbt hsbt merged commit bfefbc7 into master Mar 25, 2026
96 checks passed
@hsbt hsbt deleted the show-incorrect-dependencies-message branch March 25, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants