Skip to content

Improve error message when current platform is not in lockfile#9439

Open
55728 wants to merge 1 commit intoruby:masterfrom
55728:fix/improve-platform-mismatch-error-message
Open

Improve error message when current platform is not in lockfile#9439
55728 wants to merge 1 commit intoruby:masterfrom
55728:fix/improve-platform-mismatch-error-message

Conversation

@55728
Copy link
Copy Markdown

@55728 55728 commented Mar 30, 2026

When bundle install fails because the current platform is not included in the lockfile, the existing error message is confusing — it says it cannot find a gem for the locked platform, then immediately lists available gems that include the very platform it claimed to be missing.

This PR adds a hint to the error message explaining the actual issue and suggesting a fix.

Fixes #9413

Example

Before:

Could not find gem 'pg' with platform 'x86_64-linux-musl' in rubygems repository
https://rubygems.org/ or installed locally.

The source contains the following gems matching 'pg':
  * pg-0.7.9.2008.01.28
  ... (200+ entries, including pg-1.6.3-x86_64-linux-musl)

After:

Could not find gem 'pg' with platform 'x86_64-linux-musl' in rubygems repository
https://rubygems.org/ or installed locally.

The source contains the following gems matching 'pg':
  * pg-0.7.9.2008.01.28
  ... (same as before)

Your current platform (x86_64-linux) is not included in the lockfile's platforms
(x86_64-linux-musl). Add the current platform to the lockfile with
`bundle lock --add-platform x86_64-linux` and try again.

Implementation

Added a platform_mismatch_hint method in Bundler::Resolver that checks Bundler.locked_gems.platforms (the lockfile's PLATFORMS section) against Bundler.local_platform. When the current platform is not in the lockfile, the hint is appended to the existing error message.

@55728 55728 force-pushed the fix/improve-platform-mismatch-error-message branch from 5627262 to 02d2179 Compare March 31, 2026 10:54
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.

bundle install produces confusing error if current platform is not in Gemfile.lock

2 participants