Skip to content

Vendored gem scan on a stock Rails Gemfile fails 5 of 7 gems (group blocks, native extensions) and none of the errors says what to do, though group: at the top level and --mode hosted both work #2091

Closed

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:

  1. Declare the gem at the top level with the group: option instead of inside a group … do block. Vendored mode then accepts it.
  2. Run scan --mode hosted afterwards. 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: :development

run 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 with socket-patch scan --mode hosted";
  • native extensions and platform-specific builds: "use --mode hosted (or --mode agent) for this gem", which is what docs/ecosystems.md already 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

  1. added
    bug
    bughunt
    pm:bundler
    ux
    on Nov 15, 2026
  2. mikolalysenko commented on Nov 18, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue. Branch: agent/fix-vendored-gem-refusals-name-no-remedy.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedbugbughuntpm:bundlerpriority:p1ux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions