[BUG] EACCES on ~/.npmrc is reported as a root-owned cache folder
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
- 領域
- cli
調査の方向性
The issue points to lib/utils/error-message.js, where the cache path check is described. Read that check and reproduce the failure with the provided read-only ~/.npmrc steps. Done when the error for ~/.npmrc names the file and shows the generic permission message, while paths inside the cache still receive the cache-specific message.
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
When npm cannot write ~/.npmrc, it reports that the cache folder contains root-owned files and tells the user to run sudo chown -R on ~/.npm. The cache is fine, so the suggested command does not fix anything. The real problem is that ~/.npmrc is not writable. That happens, for example, when a dotfiles manager such as Nix Home Manager links it to a read-only file.
npm login on such a machine fails like this:
npm error code EACCES
npm error syscall open
npm error path /Users/<user>/.npmrc
npm error errno -13
npm error
npm error Your cache folder contains root-owned files, due to a bug in previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error sudo chown -R 501:20 "/Users/<user>/.npm"
Suspected cause: lib/utils/error-message.js decides that an error is inside the cache with a plain string prefix check, er.path.startsWith(npm.config.get('cache')). With the default cache ~/.npm, the path ~/.npmrc passes that check because the string ~/.npmrc starts with ~/.npm. Any sibling path that starts with the cache path, such as ~/.npm-global, would match the same way.
Expected Behavior
npm should show the root-owned cache message only for paths inside the cache directory. For ~/.npmrc, it should show the generic permission error, which names the file that could not be written.
Steps To Reproduce
export HOME="$(mktemp -d)"
printf 'fund=true\n' > "$HOME/.npmrc"
chmod 444 "$HOME/.npmrc"
npx -y [email protected] config set fund=false
npm prints path <tmp>/.npmrc followed by the root-owned cache message and a sudo chown -R command for <tmp>/.npm. npm login hits the same message, because it also saves to the user config.
Environment
- npm: 12.2.2 (also seen on 11.19.1)
- Node.js: 24.22.2 (also seen on 26.13.0)
- OS Name: macOS 27.0
- System Model Name: Apple Silicon Mac
- npm config: default, apart from a read-only
~/.npmrc
🤖 Created with Claude Opus 5.5 in T3 Code
- 主要言語
- JavaScript
- スター
- 10.3k
- フォーク
- 5k
- 平均マージ
- 4日 11時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 2 日以内に返信
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endings対応中かも @saruk-vedant が 7 日前に担当しました。 オープンBug Needs Triage Triage Requested
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
[BUG] npm pkg delete removes the first array item for a nonexistent property対応中かも @drawliin が 42 日前に担当しました。 オープンcmd:delete Priority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings logged再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンEngineering Priority 1
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 2 日以内に返信
-
`npm audit signatures` does not report how many packages it skipped for want of registry keys対応中かも @greenlincoln05 が 63 日前に担当しました。 オープンPriority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
docs: add SECURITY.md vulnerability reporting policy対応中かも @AK-Lmn が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
flisk-sh/linux2wasm#12 ·
メンテナーはふだん 1 日以内に返信
-
possible bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Mintplex-Labs/anything-llm#7388 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
メンテナーはふだん 1 日以内に返信
-
v6: Minified bootstrap.min.css is missing header info対応中かも @lazerg が今日担当しました。 オープンbug build confirmed has-pr v6
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
githubnext/gh-aw-workshop#6332 ·
メンテナーはふだん 1 日以内に返信