Agent mode reports a gem whose installed file was edited as "not installed on this host" / "not found on disk", `apply --check` says to run `apply`, and `rollback` exits 1 with "modified after patching" on every run
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
Hướng nghiên cứu
Start in crates/socket-patch-cli/src/commands/apply.rs at the "no matching variant found" error (around line 4576) and the lockfile-only note near lines 4682 and 4755, then rollback.rs for the "modified after patching" verdict. Pull request #2237 is already open against this issue, so check it before starting. Done means a modified gem file is reported as hash_mismatch and rollback skips copies that hold no patched file; reproduce with a hand-edited rack 2.2.8 in vendor/bundle.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
In agent mode, when an installed gem's file matches neither the patch's beforeHash nor its afterHash (someone edited the gem in place with bundle open, added a debug line, or the gem comes from a private gem server that rebuilt it), socket-patch correctly leaves the gem alone. But every message about it says something else is wrong, and none says what is:
scan/apply: "Failed to patch pkg:gem/[email protected]: no matching variant found", then "Note: 1 manifest patch targets a package not installed on this host (resolved by the project lockfile; skipped)" and "Applied 0 of 1 patch: 1 not found on disk". The gem is installed, in the project's ownvendor/bundle.apply --json: the only event for the gem isskipped/package_not_installed("Resolved by the project lockfile but not installed on this host (lockfile-only)"), besidestatus: partialFailure.apply --check: "Runsocket-patch applyto regenerate them."applyfails the same way every time.rollbackandremove: "Cannot roll back: lib/rack.rb - File has been modified after patching. Cannot safely roll back." (exit 1, on every run). The file was never patched.rollbacknames no way out, so the record stays in.socket/manifest.jsonand every laterrollbackexits 1; onlyremovementions--skip-rollback.
Nothing names the file that differs, says that its content is not the published gem's, or gives the fix that works: bundle pristine <gem> and then socket-patch apply.
Impact
A first-time user is told the gem is not installed while looking at it in vendor/bundle, is sent to re-run a command that cannot succeed, and ends with a manifest that makes rollback exit 1 until they find remove --skip-rollback. CI that reads --json sees package_not_installed, a code the contract calls calm ("never flips status or exit"), for what is a failed patch. No project file or gem is damaged.
Repro
Any agent-mode gem patch. I used the repo's stand-in patch service (tests/nokogiri/patch_service.rb, extended to serve /patches/blob/<hash>) for rack 2.2.8 on a loopback port; every socket-patch call also takes --api-url <mock> --patch-server-url <mock> --api-token fake --org nokogiri-e2e. Ruby 3.3.6, Bundler 4.0.18.
mkdir app && cd app
printf 'source "https://rubygems.org"\n\ngem "rack", "2.2.8"\n' > Gemfile
bundle config set --local path vendor/bundle && bundle install
echo '# debug edit' >> vendor/bundle/ruby/3.3.0/gems/rack-2.2.8/lib/rack.rb
socket-patch scan --mode agent # exit 1
socket-patch apply --check # exit 1
socket-patch rollback # exit 1, and again on every re-run
socket-patch remove pkg:gem/[email protected] # exit 1
# what actually fixes it
bundle pristine rack && socket-patch apply # "1 of 1 targeted patch applied"
Output of the scan:
Found 1 package (1 ruby)
Downloaded 1 blob
Error: Failed to patch pkg:gem/[email protected]: no matching variant found
Note: 1 manifest patch targets a package not installed on this host (resolved by the project lockfile; skipped):
- pkg:gem/[email protected]?platform=ruby
Applied 0 of 1 patch: 1 not found on disk.
Error: Some patches could not be applied.
apply --check:
Error: Patches are OUT OF SYNC:
pkg:gem/[email protected]: an installed copy matches none of the manifest's release variants (no matching variant found)
Run `socket-patch apply` to regenerate them.
rollback:
Failed to roll back:
pkg:gem/[email protected]?platform=ruby: Cannot roll back: lib/rack.rb - File has been modified after patching. Cannot safely roll back.
Error: Some patches could not be rolled back.
The same output appears for a gem a private gem server rebuilt under the same name and version (a source "<url>" do … end block around gem "rack", "2.2.8"), with another gem of the run patched fine beside it.
Expected
CLI_CONTRACT.md describes this case for gems: "a build whose bytes match no manifest variant is left untouched, fails apply (no matching variant found) and withholds the vex statement, and rollback skips it." The refusal itself is right. But:
- the same contract reserves
package_not_installedfor an "in-scope entry not installed", and the "Agent leg: copy failed" row gives a modified file the codehash_mismatchwithdetails.filesVerified. A gem whose file differs should be reported as that: the file, that its content is neither the original nor the patched one, and how to get the original back (bundle pristine <gem>, as the Ruby-gem warning ofapplyalready mentionsbundle install --redownload). rollbackshould skip a copy that holds no patched file, as the sentence above says, or at least nameremove --skip-rollback; "modified after patching" should not be said of a file that was never patched.apply --checkshould not offersocket-patch applyas the remedy whenapplycan't change the copy.
Actual
"not installed on this host", "not found on disk", package_not_installed, "Run socket-patch apply to regenerate them", and a rollback that exits 1 on every run with "modified after patching".
Versions
| Result | |
|---|---|
main e685fb1 (5.1.0 + 33 commits), Bundler 4.0.18, Ruby 3.3.6, hand-edited rack 2.2.8 in vendor/bundle |
reproduces (scan twice, apply, --check, rollback twice, remove) |
main e685fb1, Bundler 4.0.18, rack 2.2.8 rebuilt by a private gem server (source block), rake patched beside it |
reproduces |
Linux only; nothing here looks platform-specific. The messages come from the release-variant path (the patch's purl is ?platform=ruby), so other ecosystems with qualified purls may print the same; not tested here. First bad release not searched.
Suspect code
crates/socket-patch-cli/src/commands/apply.rs:4576("no matching variant found") with the lockfile-only note at:4682/:4755and the "not found on disk" tally at:2804.crates/socket-patch-cli/src/commands/apply.rs:1049(the--checkremedy).crates/socket-patch-cli/src/commands/rollback.rs(the "modified after patching" verdict for a file at neither hash).
Generated by Claude Code
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 309
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
Windows unit tests fail on main: pnpm-registry-overrides fixtures are checked out as CRLF (mixes CRLF and LF line endings)Có thể đã có người làm @mikolalysenko đã nhận hôm nay. Đang mởagent:claimed agent:triaged ci-janitor priority:p1
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#2238 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#1860 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#1838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Nightly: pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_needed fails on Windows (pnpm records the RUNNER~1 short path as a second importer)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởagent:triaged ci-janitor priority:p1
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 42/100
SocketDev/socket-patch#2235 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Behind a private gem mirror a hosted gem pin cannot be undone: `rollback` and `remove` refuse on a `CHECKSUMS` lock, and without `CHECKSUMS` `rollback` leaves the patched builds installed with no warning that names themCó thể đã có người làm @mikolalysenko đã nhận hôm nay. Đang mởagent:claimed agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 12/100
SocketDev/socket-patch#2230 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
qingjian-team/qingjian#1181 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug P2: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
leepokai/Codync#618 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
oxidecomputer/opte#1125 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] StreamLifecycleConfig clamps post-TTFT stream timeouts to remaining admission budgetCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
lbjlaq/Antigravity-Manager#4063 ·
Maintainer thường phản hồi trong vòng 1 ngày