Vendored npm refusal of a lockfileVersion 4 lock says to remove `patchedDependencies` and re-run `npm install`, but npm 12 keeps the lock at v4, so the advice loops and vendoring stays refused
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- json, rust
調査の方向性
Start in crates/socket-patch-core/src/vendor/npm_lock.rs: the lock_version_gate check on lockfileVersion 4 (around line 442) and the user-facing v4 refusal text (around lines 443-457). Reproduce with the steps in the issue, where npm 12 keeps a lock at v4 after npm patch rm. Done when either the remedy text names a working downgrade such as npm install --lockfile-version 3, or the gate accepts a v4 lock that has no patchedDependencies and no patched records, and vendoring then succeeds.
索引モデルが issue の本文から書いたものです。
説明
[agent] Found by the scheduled npm bug-hunt routine (ledger #302).
Summary
Vendored mode refuses an npm 12 lockfileVersion: 4 lock with vendor_lockfile_version_unsupported (the #711 fix). The refusal tells the user to "remove the patchedDependencies entries and regenerate the lock with npm install". That doesn't work. Once npm 12.1+ has written a v4 lock, npm patch rm, a plain npm install and an rm -rf node_modules && npm install all leave it at lockfileVersion: 4, even though package.json has no patchedDependencies and no entry carries a patched record. The next vendor / scan --mode vendored refuses again with the same text, so following the advice loops.
The gate's own comment (npm_lock.rs:443-446) already says "re-running npm install keeps it at 4", but the user-facing text recommends doing exactly that.
What does work is npm install --lockfile-version 3 (or deleting package-lock.json and reinstalling). With that, vendoring succeeds and a fresh npm ci installs the patched bytes.
Impact
A user who has ever used npm patch (npm >= 12.1) can't move to vendored mode by following the CLI's instructions. Each attempt exits 1 with the same refusal. This is the same "advice loops" class as #1072. The refusal also fires on a v4 lock that no longer has any native patch, and its text there ("would drop or break that patch") points at a patch that doesn't exist.
Repro (npm 12.2.0 or 12.1.0, Linux, main e76cb9b)
mkdir p && cd p
echo '{"name":"p","version":"0.0.0","private":true}' > package.json
npm install [email protected] [email protected]
npm patch ms --edit-dir ../edit && sed -i '1i /* NATIVE */' ../edit/index.js && npm patch commit ../edit
# package-lock.json: lockfileVersion 4
# stage a [email protected] patch in .socket/manifest.json (or use get/scan --mode vendored)
socket-patch vendor --json # vendor_lockfile_version_unsupported (expected: a native patch is present)
# Follow the advice:
npm patch rm ms # package.json no longer has patchedDependencies
npm install # lockfileVersion is still 4
rm -rf node_modules && npm install # still 4
socket-patch vendor --json # vendor_lockfile_version_unsupported again, same text
# What actually works:
npm install --lockfile-version 3 # lockfileVersion 3
socket-patch vendor --json # applied
rm -rf node_modules && npm ci # left-pad installs the patched bytes
I drove vendor with the repo's prebuilt patch-service fixture (tests/prebuilt_common) over the real installed bytes. Every npm step is a real npm install.
Expected vs actual
- Expected: a refusal's remedy, followed literally, clears the refusal. docs/testing/npm-compatibility.md ("npm 12 notes") documents the refusal as "naming
npm patch". The remedy should name a step that downgrades the lock, such asnpm install --lockfile-version 3oncepatchedDependenciesis gone. Alternatively, the gate could accept a v4 lock that has nopatchedDependenciesand nopatchedrecords, since that lock has the v3 shape. - Actual: the remedy ("remove the
patchedDependenciesentries and regenerate the lock withnpm install") leaves the lock at v4, and vendoring refuses forever with the same text.
Matrix (Linux, Node 22.22, main e76cb9b)
| npm | lfv after npm patch |
after npm patch rm + npm install |
after rm -rf node_modules + npm install |
vendor after the advice |
after npm install --lockfile-version 3 |
|---|---|---|---|---|---|
| 12.2.0 | 4 | 4 | 4 | refused (repro ×2) | 3, vendor applied, npm ci patched |
| 12.1.0 | 4 | 4 | 4 | refused | 3, vendor applied |
npm <= 12.0 never writes v4, so it isn't affected. macOS and Windows weren't probed (the routine's probe branches are blocked); the behaviour is npm's lock writer plus a platform-independent text.
Suspect code
crates/socket-patch-core/src/vendor/npm_lock.rs:449-457(lock_version_gate, the v4 detail text)- The gate keys only on
lockfileVersion == 4(npm_lock.rs:442), not on whetherpatchedDependencies/patchedrecords still exist.
No probe runs: Linux only.
- 主要言語
- Rust
- スター
- 8
- フォーク
- 1
- 平均マージ
- 16時間 18分
- マージ済み PR(30日)
- 587
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SocketDev/socket-patch のほかの issue
-
agent:triaged bug bughunt pm:pipenv priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SocketDev/socket-patch#1608 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged bug bughunt pm:vlt priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
SocketDev/socket-patch#1601 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
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]対応中かも @mikolalysenko が 4 日前に担当しました。 オープン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
-
[1.x Bug] run-operation --sql reports success but rolls back writes on transaction-capable adaptersオープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
dbt-labs/dbt#16784 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:cli bug good first issue priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commit対応中かも @myOmikron が今日担当しました。 オープンbug ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
platform:windows tool triaged wontfix
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
resources: add a regression test confirming admin mint still works after the #16 SAC handoff対応中かも @Daniexie が今日担当しました。 オープンcontracts good first issue Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OlaGreat/starbound-realms#137 · コメント 1 件 ·