Skip to content

Fix the gem plain-entry remedy for uncovered platforms (#2284) - #2300

Open
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
mainfrom
agent/fix-gem-plain-entry-remedy-platforms
Open

Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
mainfrom
agent/fix-gem-plain-entry-remedy-platforms

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2284

Summary

Vendored mode refuses a gem that Gemfile.lock holds as a plain name (version) entry beside its platform gems (platform_gem_unsupported). The refusal told the user to run bundle lock --remove-platform ruby. On the lock Bundler 4 writes for a default Rails 8 app that command does not clear thruster or nokogiri, and running it a second time fails.

The refusal now reads the lock's PLATFORMS and names each platform that keeps the plain entry, with one command that removes them. Only the message changes: what is refused, the error code and the exit code are the same, and nothing new is written.

Lock Before After
ruby is the only platform no build serves --remove-platform ruby the same text
thruster, PLATFORMS has arm-linux-gnu, arm-linux-musl, ruby --remove-platform ruby (entry stays) --remove-platform arm-linux-gnu arm-linux-musl ruby
the same lock without ruby (Bundler 4's default) --remove-platform ruby (command fails) --remove-platform arm-linux-gnu arm-linux-musl
no PLATFORMS, or every locked platform is served --remove-platform ruby says what keeps the entry, --remove-platform <platform>

Root cause

platform_lock_refusal in crates/socket-patch-core/src/vendor/gem.rs printed fixed text keyed on "the lock has a plain entry" and never read PLATFORMS. Bundler keeps the plain entry for ruby and for every other locked platform that none of the gem's platform builds serves. thruster 0.1.28 ships no 32-bit ARM build, so arm-linux-gnu and arm-linux-musl keep its plain entry whether or not ruby is locked.

The change

  • formats/gem/platform.rs (new): a port of RubyGems' Gem::Platform#=== (which locked platform a platform gem serves) for Linux, macOS, Windows and Java names. It is used for wording only. A platform it cannot read is never named.
  • formats/gem/mod.rs: locked_platforms, the lines of the lock's PLATFORMS section (LF or CRLF).
  • vendor/gem.rs: plain_entry_remedy builds the last sentence of the refusal from those two.
  • CLI_CONTRACT.md and docs/ecosystems.md describe the new wording.

The wrappers under npm/, pypi/ and gem/ need no change.

Safety: PLATFORMS is a committed file section and the remedy is a command the user copies. Only a platform in the plain gem-token charset that does not start with a dash is printed (the_plain_entry_remedy_prints_no_unsafe_platform).

Evidence

Red to green: the first commit after the empty one (ea78701) adds four tests that fail on main; 11fa872 makes them pass.

cargo test -p socket-patch-core --lib          # 8655 passed, 0 failed, 1 ignored
cargo clippy --locked --workspace --all-features -- -D warnings   # clean (CI's command)

Tests that cover #2284, all in vendor::gem::tests::platform_gems:

  • the_plain_entry_remedy_names_every_platform_no_build_serves (LF and CRLF): the issue's lock; thruster's remedy lists the two ARM platforms and ruby, nokogiri keeps the one-platform remedy.
  • the_plain_entry_remedy_never_names_a_ruby_platform_the_lock_lacks: the lock after the old remedy was followed.
  • the_plain_entry_remedy_names_no_platform_it_cannot_find, ..._names_a_repeated_platform_once, ..._words_one_platform_as_one, ..._says_when_it_could_not_read_a_platform, ..._prints_no_unsafe_platform.

The platform match is checked against RubyGems itself: formats::gem::platform::tests::serves_agrees_with_rubygems_on_every_pair holds the answers RubyGems 3.5.22 gave for all 441 pairs of 21 platform names.

Real Bundler 4.0.18 on the issue's project (nokogiri 1.19.7, thruster 0.1.28): both commands the new message prints clear the plain entries.

bundle lock --remove-platform arm-linux-gnu arm-linux-musl        # default lock: thruster (0.1.28) is gone
bundle lock --add-platform ruby
bundle lock --remove-platform arm-linux-gnu arm-linux-musl ruby   # both plain entries are gone

Not run locally: the Bundler end-to-end suites. No end-to-end test asserts on this text, and the refusal is raised before any file is written or the patch service is asked.

cargo clippy -p socket-patch-core --all-targets reports 71 errors in test code on main as well; none is in a line this PR adds. CI's clippy job does not lint test targets.

Code review

/code-review high ran on the diff. All six findings are fixed in the last commit, each with a test: a repeated PLATFORMS line, a platform the port cannot read (the remedy now says another platform may keep the entry), a leading dash, the wording for one platform, and two parser differences from RubyGems.

Not in this PR

https://claude.ai/code/session_011f9aeScTQvGaMvmNNeLBiM


Generated by Claude Code

Refs #2284. Empty commit that opens the draft pull request; the fix
follows.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeScTQvGaMvmNNeLBiM
Four unit tests for #2284 that fail on main. A gem locked as a plain
entry beside platform gems is refused with a remedy that names only
`bundle lock --remove-platform ruby`. Bundler keeps the plain entry
for every locked platform that none of the gem's builds serves, so
the tests expect the remedy to name those platforms, to leave out a
ruby platform the lock does not hold, and to print no platform that
is not a plain gem token.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeScTQvGaMvmNNeLBiM
Vendored mode refuses a gem the lock holds as a plain entry beside
platform gems, and told the user to run `bundle lock
--remove-platform ruby`. Bundler keeps the plain entry for every
locked platform that none of the gem's platform builds serves, not
only for ruby. On the lock Bundler 4 writes for a default Rails 8
app that command leaves thruster and nokogiri as they were, and
running it again fails.

The refusal now reads the lock's PLATFORMS and names each platform
that keeps the entry, with one command that removes them. It names
ruby only when the lock holds it, and no platform when the lock
shows none. Which build serves which platform is a port of
RubyGems' Gem::Platform#=== for Linux, macOS, Windows and Java,
checked against a table that RubyGems 3.5.22 produced. A platform
the port cannot read, or one that is not a plain gem token, is
never printed.

Fixes #2284

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeScTQvGaMvmNNeLBiM
Findings of the code review of this branch, each with a test:

- A PLATFORMS line the lock repeats was printed twice, and Bundler
  refuses `--remove-platform ruby ruby`. Each platform is named
  once.
- A locked platform the port cannot read (FreeBSD) may keep the
  plain entry too. The remedy no longer reads as complete then: it
  adds that another locked platform may keep the entry.
- A PLATFORMS line that starts with a dash is not printed into the
  command.
- One platform other than ruby is worded as one.
- Names RubyGems reads as AIX, Cygwin or FreeBSD are not taken for
  Linux or macOS, and i386 to i686 are found anywhere in the CPU.

Refs #2284

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeScTQvGaMvmNNeLBiM
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 27, 2026 02:16
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
User-facing error text and advisory parsing only; vendoring refusal logic and exit behavior are unchanged aside from safer platform names embedded in suggested shell commands.

Overview
Fixes platform_gem_unsupported guidance when vendoring a gem whose Gemfile.lock still has a plain name (version) entry next to platform-specific builds. The refusal used to always suggest bundle lock --remove-platform ruby, which often leaves the entry in place (e.g. thruster on Rails 8 locks without 32-bit ARM builds) or suggests ruby when it is not in PLATFORMS.

The error text now parses the lock’s PLATFORMS lines and, via a new RubyGems Gem::Platform#=== port in formats/gem/platform.rs, lists every locked platform that no vendored build serves—including ruby only when it is locked—and prints a single bundle lock --remove-platform … command. Unreadable or unsafe platform strings are omitted from the command with a caveat. CLI_CONTRACT.md and docs/ecosystems.md describe the new wording; refusal behavior, exit codes, and what gets written are unchanged.

Reviewed by Cursor Bugbot for commit 43dd5a0. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 43dd5a0. Configure here.

@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver.

What it does. When vendored mode refuses a gem that Gemfile.lock holds both as platform gems and as a plain name (version) entry, the message used to always say bundle lock --remove-platform ruby. That fails or does nothing on Bundler 4's default Rails lock (#2284). The message now reads the lock's PLATFORMS and names every platform that keeps the plain entry. Only the wording changes: the error code, exit code and what gets refused stay the same.

Risk: low. Only an error message changes, on a path that refuses before anything is written. The new RubyGems platform matcher is used only to build that text, and it is checked against RubyGems 3.5.22's answers for 441 platform pairs.

Look here

Verified. Read the whole diff. CHANGELOG.md is untouched, and there is no debug code or unrelated edit. Ran cargo test -p socket-patch-core --lib filtered to formats::gem, vendor::gem::tests::platform_gems (which include the new tests): 112 passed. On CI, clippy and every other check pass. ci-ok is red only because hosted-e2e fails on gem_bundler_hosted_install_proof. That's the production-patch pin failure tracked in #2270, which also fails on main, and #2280 fixes it.

Changes I made. None.

Open questions. One wording nit, not a blocker: the first sentence of the refusal still says (the ruby platform) and "nothing for the ruby platform", even when the lock has no ruby (Bundler 4's default) and the entry is kept for arm-linux-gnu/arm-linux-musl. The remedy sentence after it is correct.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendored gem refusal names bundle lock --remove-platform ruby, which does not clear thruster or nokogiri on a default Rails 8 lock from Bundler 4.1

2 participants