Gem `BUNDLE_GEMFILE` check compares paths lexically, so a symlinked spelling of the project's own Gemfile (e.g. macOS `/tmp/app/Gemfile`) is refused, and `vex` / `rollback` reject the hosted patch Bundler is loading
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 crates/socket-patch-core/src/formats/gem/manifest.rs,從第 138-147 行附近的 resolve_against 函式,以及第 183-189 行的 manifest 比較開始。修正應在將 BUNDLE_GEMFILE 與專案根目錄進行比較時正規化路徑(或使用檔案身分),以便接受指向同一個 Gemfile 的符號連結路徑。完成的標準是 issue 中的重現案例能正常運作:在含有符號連結的專案上設定 BUNDLE_GEMFILE=$PWD/Gemfile 後,不再回傳 redirect_gem_bundle_gemfile_unsupported。
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
formats::gem::manifest::classify decides whether BUNDLE_GEMFILE names the project's own Gemfile / gems.rb by comparing std::path::absolute + normalize_lexically of the setting against the project root. It never resolves symlinks. The root comes from the process cwd (getcwd, the physical path) or --cwd. A shell's $PWD, and paths people type, are often the logical path through a symlink. So BUNDLE_GEMFILE=$PWD/Gemfile names the same file Bundler loads, but socket-patch classifies it as "another manifest" (LoadedManifest::Unsupported).
On macOS this is the default for anything under /tmp (→ /private/tmp) or $TMPDIR (/var/folders/… → /private/var/…). On Linux it hits any project reached through a symlinked directory (a symlinked workspace or home, /app → volume, and so on).
Impact
All of these fail closed, but each one stops socket-patch from working on a correctly configured project, with a message that's factually wrong:
- Hosted
scanredirects nothing:redirect_gem_bundle_gemfile_unsupported("bundler loads/tmp/bh-app/Gemfile… not the project's Gemfile or gems.rb"). That is the project's Gemfile. vexon an already-redirected project whose install is patched (Bundler loads the patched gem) refuses with exit 2: "BUNDLE_GEMFILE points bundler at another manifest, so this wiring is never installed and the patch is not attested". It also suggests deletingGemfile.lock, which is the lock Bundler uses.rollback/removeerror out withpatched_ref_unattributablefor the same reason, so the hosted patch can't be unwound while the variable is set.
The same function backs bundler_loaded_lock_in (lock inventory, ledger recovery, VEX discovery) and the vendored manifest check, so every gem lock reader inherits this.
Repro (Linux; the ln -s stands in for macOS /tmp)
mkdir -p real/app && ln -s "$PWD/real" link && cd link/app
printf 'source "https://rubygems.org"\n\ngem "colorize", "0.8.1"\ngem "rainbow"\n' > Gemfile
bundle config set --local path vendor/bundle && bundle install && bundle lock --add-checksums
echo "PWD=$PWD physical=$(pwd -P)"
BUNDLE_GEMFILE=$PWD/Gemfile bundle exec ruby -e 'puts Bundler.default_lockfile' # → link/app/Gemfile.lock (same file)
A="--api-url <mock> --org org --api-token fake --patch-server-url <mock>"
socket-patch scan --mode hosted --json --yes --dry-run $A # redirected: 1
BUNDLE_GEMFILE=$PWD/Gemfile socket-patch scan --mode hosted --json --yes --dry-run $A # redirected: 0, redirect_gem_bundle_gemfile_unsupported
BUNDLE_GEMFILE=$(pwd -P)/Gemfile socket-patch scan --mode hosted --json --yes --dry-run $A # redirected: 1
# after a real redirect (no env) + bundle install → installed gem is patched:
BUNDLE_GEMFILE=$PWD/Gemfile socket-patch vex --product pkg:gem/app@1 $A # exit 2 ("never installed")
BUNDLE_GEMFILE=$PWD/Gemfile socket-patch rollback --dry-run --json --yes $A # status error, patched_ref_unattributable
The same refusal happens for --cwd <symlinked path> with BUNDLE_GEMFILE=<physical path>, and for .bundle/config BUNDLE_GEMFILE: "<symlinked abs path>/Gemfile" (as written by bundle config set --local gemfile "$PWD/Gemfile"), with no environment variable at all.
Expected vs actual
- Expected, per docs/ecosystems.md (RubyGems row):
BUNDLE_GEMFILE"is followed when it names the project'sGemfile/gems.rb, and any other configured manifest is refused". Bundler expands the path and resolves it to the same file and the sameGemfile.lock(Bundler.default_lockfileabove), so socket-patch should treat it as the project'sGemfile. - Actual: the refusal fires when it shouldn't (a false
Unsupported), and the VEX / rollback messages claim Bundler uses a different manifest.
Matrix (Bundler 4.0.22)
| OS | Setup | Unset | BUNDLE_GEMFILE=$PWD/Gemfile (logical) |
BUNDLE_GEMFILE=$(pwd -P)/Gemfile |
|---|---|---|---|---|
| macos-latest, Ruby 3.4.9 | project in /tmp/bh-app (physical /private/tmp/bh-app) |
redirected 1 | refused | redirected 1 |
| ubuntu-latest, Ruby 3.4 | project via symlinked dir | redirected 1 | refused | redirected 1 |
| Linux sandbox, Ruby 3.3.6 | same, plus vex / rollback after a real redirect + install (2/2) |
vex ok | vex exit 2, rollback error (installed gem is patched) | — |
| Linux sandbox | --cwd <link> + env <real> / config abs <link> path |
— | refused / refused | — |
Probe run: https://github.com/SocketDev/socket-patch/actions/runs/37382646373 (the probe's own vex/rollback cells hit a stale vendor/bundle harness artifact; the Linux sandbox rows cover them).
First bad commit
9d718cf5 (#431, the fix for #341 / #390), which introduced the BUNDLE_GEMFILE classification with a lexical compare; cbf1f748 (#532) kept it. The v4.0.0 release binary ignores BUNDLE_GEMFILE and redirects this project (it predates the classification), so this hasn't shipped in a release yet.
Suspect code
crates/socket-patch-core/src/formats/gem/manifest.rs:138-147(resolve_against:absolute+normalize_lexicallyonly) and:183-189(target == root.join(manifest)).- The same lexical compare is in
env_keeps_root(manifest.rs:163-166), which decides whether the env var moves Bundler's root.
Comparing canonicalized paths (or file identity, same_file-style) whenever both exist would match what Bundler does. A lexical match could stay as the fast path, falling back to canonicalization only when it fails, so a symlinked Gemfile file (already refused elsewhere) keeps its own handling.
- 主要語言
- Rust
- 星號
- 8
- 分支
- 0
- 平均合併
- 1 天 7 分鐘
- 30 天內合併 PR
- 178
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
Hosted yarn classic pins give no berry-migration warning, so a yarn 2+ install silently drops them (vendored warns about the same trap)可能已有人在做 @mikolalysenko 於 1 天前認領。 未關閉agent:claimed agent:triaged bug bughunt pm:yarn-classic priority:p1
難度 2/5 1-3 小時 新手友好度 85/100
SocketDev/socket-patch#907 · 2 則留言 ·
維護者通常 1 天內回覆
-
vendor --check fails a vendored package whose lock is contested by a sibling package-lock.json with "no lockfile or config references .socket/vendor/… any more", which is false, and its remedy ("re-run socket-patch vendor") is a no-op, so the check stays red forever可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:npm priority:p1
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#900 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
難度 2/5 1-3 小時 新手友好度 73/100
SocketDev/socket-patch#783 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:pipenv priority:p1
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#744 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:cargo priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#651 · 3 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
CommunityToolkit/Aspire#2231 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 1/5 1 小時以內 新手友好度 78/100
vercel-labs/agent-browser#2063 ·
維護者通常 4 天內回覆
-
agent/sec-check hive/hive-school-tunaos security
難度 2/5 1-3 小時 新手友好度 90/100
維護者通常 1 天內回覆