Repository navigation
Description
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
On the Gemfile rails new generates (Rails 7.1), scan --mode vendored fails 5 of 7 patched gems and exits 1. Each error says why the gem was refused and nothing about what to do next. Two remedies exist and both work, but the user has to guess them:
- Declare the gem at the top level with the
group:option instead of inside agroup … doblock. Vendored mode then accepts it. - Run
scan --mode hostedafterwards. It patches the group-block gems and the gems with native extensions that vendored mode refused, and leaves the vendored ones alone.
The refusals themselves are by design (#340, and "Ruby gems: native extensions" in docs/ecosystems.md). This issue is about the messages.
Impact
Friction on the most common Bundler project shape. Every Rails Gemfile declares its development and test gems in group … do blocks, and puma and bootsnap build native extensions, so a first-time user of vendored mode gets an exit 1 and a list of errors with no next step. docs/usage.md does not mention Ruby gems, groups or native extensions in its vendoring section. Hosted mode's warnings for the same kind of refusal do say what to do ("Write it as one gem "<name>", … call…", "--mode vendored or --mode agent can still patch a gem hosted mode skips").
Repro
Bundler 4.0.18, Ruby 3.3.6; patches for bootsnap, capybara, nokogiri, puma, rack, rails-html-sanitizer and web-console (local mock of the patch API).
gem install rails -v 7.1.5
rails new app --skip-git --skip-javascript --skip-hotwire --skip-asset-pipeline --skip-docker
cd app && git init -q . && bundle config set --local path vendor/bundle && bundle install
socket-patch scan --mode vendored ; echo "exit $?"Error: Cannot vendor pkg:gem/bootsnap@1.26.1: bootsnap-1.26.1.gemspec declares native extensions; bundler does not build extensions for path-sourced gems
Error: Cannot vendor pkg:gem/capybara@3.40.0: the `gem "capybara"` declaration is indented (inside a group/conditional block)
Error: Cannot vendor pkg:gem/nokogiri@1.19.7: installed dir `nokogiri-1.19.7-x86_64-linux-gnu` is not the portable `nokogiri-1.19.7` gem (platform-specific or unexpected gem builds cannot be vendored portably)
Error: Cannot vendor pkg:gem/puma@8.1.1: puma-8.1.1.gemspec declares native extensions; bundler does not build extensions for path-sourced gems
Error: Cannot vendor pkg:gem/web-console@4.2.1: the `gem "web-console"` declaration is indented (inside a group/conditional block)
Vendored 2 packages; 5 failed.
pkg:gem/rack@3.2.8: fixes CVE-2026-0001
pkg:gem/rails-html-sanitizer@1.7.2: fixes CVE-2026-0001
Next steps:
1. Commit .socket/vendor/ and the updated lockfiles to make the patches portable.
2. Reinstall from the updated lockfile so the installed packages pick up the vendored artifacts, then run `socket-patch vex` to verify the installed patches.
exit 1
Remedy 1, verified: replace the two block declarations with
gem "capybara", group: :test
gem "web-console", group: :developmentrun bundle install, and re-run the scan: "Vendored 4 packages; 3 failed." The rewritten lines keep the option (gem "capybara", "3.40.0", path: ".socket/vendor/gem/…/capybara-3.40.0", group: :test), a deployment install with BUNDLE_WITHOUT=development:test skips them, and rollback restores the pair.
Remedy 2, verified: socket-patch scan --mode hosted on the project as the vendored scan left it prints "Switched 4 packages to hosted patches" (bootsnap, capybara, puma, web-console), a frozen install passes, the app loads all six patched gems and vex attests all six. (Undoing that mixed state is broken at the moment: #2090.)
Expected
Each refusal names a way forward, as the hosted warnings do. For example:
- group block: "declare it at the top level with
group: :test, or patch it withsocket-patch scan --mode hosted"; - native extensions and platform-specific builds: "use
--mode hosted(or--mode agent) for this gem", which is whatdocs/ecosystems.mdalready says for agent mode ("Use hosted mode for those").
A line in the summary saying that the refused gems can be patched in hosted mode would also help, since the exit code is 1 while two gems were vendored and the next steps read as if the run had succeeded.
Actual
The errors state the cause only. The next steps do not mention the five gems that were left unpatched.
Versions
| Bundler | Ruby | Result |
|---|---|---|
| 4.0.18 | 3.3.6 | reproduces (Rails 7.1 app twice, and a 2-gem project) |
| 2.6.9, 2.5.22 | 3.3.6 | same messages on the 2-gem project |
Tested on main 63f791d (5.1.0), Linux. The messages are the same on every platform.
Suspect code
crates/socket-patch-core/src/vendor/gem.rs:1339("declaration is indented (inside a group/conditional block)")crates/socket-patch-core/src/vendor/gem.rs:418("declares native extensions; …")crates/socket-patch-core/src/vendor/gem.rs:350("is not the portable … gem")
Generated by Claude Code
Activity
bundler: 2026-11-15 run 2 (#2089, #2090, #2091)
mikolalysenko commentedon Nov 18, 2026
[agent] Claiming this issue. Branch: agent/fix-vendored-gem-refusals-name-no-remedy.
Generated by Claude Code
Test that vendored gem refusals name a remedy
Name a remedy in vendored gem refusals
Fit each gem refusal's remedy to its cause
Drop needless borrows in gem remedies
Word the hosted remedy for an eject too
Skip hosted in native remedy for source gems