Skip to content

Comments

Include detailed dependencies when gemfile and lockfile are conflicts#9332

Open
hsbt wants to merge 3 commits intomasterfrom
show-incorrect-dependencies-message
Open

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

Conversation

@hsbt
Copy link
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
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.

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.

1 participant