Go go.work audit: false NotAMember for a use path through a missing dir on macOS (breaks macOS test job)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 76/100
研究方向
從 crates/socket-patch-core/src/vendor/go_consumer_sync.rs 中的 same_dir_key 開始,並搭配失敗的測試 go_work_that_does_not_use_the_project_makes_the_replace_inert 閱讀它的文件註解。將 TMPDIR 指向透過符號連結連接的目錄,執行針對 go_consumer_sync 的測試以重現失敗。當經過不存在目錄的使用路徑與專案根目錄相符,且 macOS 上錯誤的 NotAMember 衝突受到測試涵蓋時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
[agent] Found while checking the full-scope CI run for #1407. It breaks the macOS test job, so tonight's nightly on main is expected to go red.
What fails
vendor::go_consumer_sync::tests::go_work_that_does_not_use_the_project_makes_the_replace_inert (added in #1393, merged 2026-10-11 19:48 UTC, after the last nightly) fails on macos-latest: run 38191238691, job 114624594929.
panicked at crates/socket-patch-core/src/vendor/go_consumer_sync.rs:923:13:
assertion `left == right` failed: ./x/../app
left: [Workspace { module: "example.com/upstream", version: "v1.0.0", conflict: NotAMember { work_file: "/private/var/folders/.../go.work" } }]
right: []
The spellings ./app, app, ./app/ and "./app" all pass. Only ./x/../app fails.
Root cause
same_dir_key (go_consumer_sync.rs:468) calls std::fs::canonicalize on the raw joined path <ws>/x/../app. canonicalize needs every component to exist, and x doesn't, so the call errors and the code falls back to the lexical path /var/.../app. The project root does exist and canonicalizes to /private/var/.../app, because /var is a symlink on macOS. The two keys differ, so the use entry doesn't match the project and the audit reports NotAMember.
It isn't only a test problem. Any user whose go.work use path passes through a directory that doesn't exist, and whose project sits under a symlinked path (macOS /var or /tmp, a symlinked home or checkout), gets a false "go.work does not use this project" conflict. Go itself resolves use paths lexically (filepath.Clean), so ./x/../app is a valid member for go.
Repro on Linux
Point TMPDIR at a symlinked directory:
mkdir -p /tmp/real && ln -sfn /tmp/real /tmp/link
TMPDIR=/tmp/link cargo test -p socket-patch-core --lib go_consumer_sync
# 8 passed; 1 failed (same assertion)
Proposed fix (verified locally)
Normalize lexically first, then canonicalize. This matches go's filepath.Clean and still resolves symlinks when the cleaned path exists:
fn same_dir_key(dir: &Path) -> PathBuf {
let abs = std::env::current_dir().unwrap_or_default().join(dir);
- std::fs::canonicalize(&abs)
- .unwrap_or_else(|_| crate::utils::relpath::normalize_lexically_keeping_escapes(&abs))
+ let lexical = crate::utils::relpath::normalize_lexically_keeping_escapes(&abs);
+ std::fs::canonicalize(&lexical).unwrap_or(lexical)
}
With this patch, TMPDIR=/tmp/link cargo test -p socket-patch-core --lib go_consumer_sync gives 9 passed. The rest of vendor:: matches main: the only two failures, pypi_poetry::...wire_write_failure... and pypi_requirements::...wire_failure_rolls_back..., fail on unpatched main too when run as root in the agent sandbox.
This is product code in the Go lane (first issue-fixer instance), so I haven't claimed it. The doc comment above same_dir_key should be updated with the fix.
Generated by Claude Code
- 主要語言
- Rust
- 星號
- 8
- 分支
- 1
- 平均合併
- 18 小時 19 分鐘
- 30 天內合併 PR
- 504
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:npm priority:p3 ux
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1072 · 2 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
難度 2/5 1-3 小時 新手友好度 73/100
SocketDev/socket-patch#783 · 1 則留言 ·
維護者通常 1 天內回覆
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:cargo priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#651 · 3 則留言 ·
維護者通常 1 天內回覆
-
bug bughunt pm:npm
難度 4/5 3-5 天 新手友好度 45/100
SocketDev/socket-patch#1481 ·
維護者通常 1 天內回覆
-
Hosted gem scan ignores a Gemfile `lockfile "custom.lock"` DSL call (Bundler 4), so it pins the unused Gemfile.lock, leaves the real lock untouched, and every frozen install fails可能已有人在做 @mikolalysenko 今天認領。 未關閉agent:claimed agent:triaged bug bughunt pm:bundler priority:p1
難度 4/5 3-5 天 新手友好度 35/100
SocketDev/socket-patch#1477 · 3 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
project-robius/robrix#1154 ·
維護者通常 1 天內回覆
-
Add Mimir未關閉
難度 1/5 1 小時以內 新手友好度 78/100
slavakurilyak/awesome-ai-agents#759 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
compiler-explorer/compiler-explorer#9272 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 63/100
pop-os/cosmic-files#2117 ·
維護者通常 2 天內回覆