Repository navigation
Description
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
socket-patch scan --mode agent --no-gem-native-rebuild (and SOCKET_NO_GEM_NATIVE_REBUILD=1 socket-patch scan --mode agent) ignores the opt-out: it runs the gem's extconf.rb and make, replaces the installed extension, prints no native_extension_not_rebuilt warning, and vex attests the patch. apply --no-gem-native-rebuild and get <uuid> --mode agent --no-gem-native-rebuild honor it on the same project.
Impact
The flag exists for callers that must not have socket-patch compile anything (the patches evaluation harness, a CI step without a toolchain, a policy against running gem build scripts from this tool). With scan, the build scripts run anyway. Where there is no compiler the opt-out was the way to avoid a native_extension_build_failed failure, and it does not work.
Repro
Any agent-mode gem patch that changes ext/** sources. I used a mock patch for puma 6.6.1 that appends a string constant to ext/puma_http11/puma_http11.c.
bundle config set --local path vendor/bundle && bundle install # puma 6.6.1 built from source
socket-patch scan --mode agent --yes --no-gem-native-rebuild
ls vendor/bundle/ruby/3.3.0/gems/puma-6.6.1/.socket-patch-native-build.json # exists: it rebuilt
grep -c SOCKET_PATCHED_NATIVE vendor/bundle/ruby/3.3.0/gems/puma-6.6.1/lib/puma/puma_http11.so # 1
socket-patch vex --product pkg:gem/app@1.0.0 # attests pumaExpected
docs/ecosystems.md, "Ruby gems: native extensions": "A tool that compiles the extension itself after apply […] passes --no-gem-native-rebuild (or SOCKET_NO_GEM_NATIVE_REBUILD=1): the sources are written without a rebuild, with a native_extension_not_rebuilt warning, and vex does not attest them." The flag's own help names scan: "Agent mode (apply, scan/get --mode agent): write a gem patch that changes native-extension sources WITHOUT rebuilding the extension".
Actual
$ socket-patch scan --mode agent --yes --no-gem-native-rebuild
Applying patches...
Warning: Ruby gem: `bundle install --redownload` will revert these patches by reinstalling from the cached .gem.
Patched packages:
pkg:gem/puma@6.6.1 (via blob)
…
$ grep -c SOCKET_PATCHED_NATIVE …/extensions/x86_64-linux/3.3.0/puma-6.6.1/puma/puma_http11.so …/gems/puma-6.6.1/lib/puma/puma_http11.so
1
1
$ socket-patch vex …
Emitted 3 VEX statements
Control, same project after bundle pristine puma:
$ socket-patch apply --no-gem-native-rebuild
Warning: pkg:gem/puma@6.6.1: the patch changes native-extension sources (ext/puma_http11/puma_http11.c), written without rebuilding the extension (--no-gem-native-rebuild); Ruby loads the old build until it is recompiled, and vex does not attest it
$ grep -c SOCKET_PATCHED_NATIVE … (both .so files)
0
0
$ socket-patch vex …
Warning: omitting pkg:gem/puma@6.6.1 from VEX: the patched native-extension sources were not compiled into the extension Ruby loads; run socket-patch apply to rebuild it (native_extension_not_rebuilt)
Emitted 2 VEX statements
Versions
| Command | Result |
|---|---|
scan --mode agent --yes --no-gem-native-rebuild |
rebuilds (bug), 2 runs |
SOCKET_NO_GEM_NATIVE_REBUILD=1 scan --mode agent --yes |
rebuilds (bug) |
apply --no-gem-native-rebuild |
honors the flag |
get <uuid> --mode agent --yes --no-gem-native-rebuild |
honors the flag |
main 7c5240e (5.1.0), Ruby 3.3.6, Bundler 2.6.9, Linux. Not Bundler-version or platform specific as far as the code goes. First bad release: the flag arrived with #1998 in 5.1.0, and I did not find a version where scan honored it.
Suspect code
crates/socket-patch-cli/src/commands/agent_download.rs:1364 (nested_apply_args_from_params): scan's nested apply rebuilds a GlobalArgs from DownloadParams and fills the rest with ..GlobalArgs::default(), so no_gem_native_rebuild is always false there (and the env var, which clap only reads on the top-level parse, is lost too). get passes its own args.common through nested_apply_args (commands/get.rs:2129), which is why it works. apply.rs:2989 then reads rebuild: !args.common.no_gem_native_rebuild. Other fields dropped the same way may deserve a look.
Generated by Claude Code
Activity
bundler: run 2026-11-13 (main 7c5240e), filed #2069 #2070
mikolalysenko commentedon Nov 13, 2026
[agent] Claiming this issue. Branch: agent/fix-scan-drops-no-gem-native-rebuild.
Generated by Claude Code
Test scan honoring --no-gem-native-rebuild
Carry --no-gem-native-rebuild into scan's apply
Start scan's nested apply from the caller's flags