[BUG] EACCES on ~/.npmrc is reported as a root-owned cache folder
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- cli
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- JavaScript
- Stelle
- 10.3k
- Fork
- 5k
- Merge medio
- 4g 11h
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsForse già presa @saruk-vedant l’ha presa 7 giorni fa. ApertaBug Needs Triage Triage Requested
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyForse già presa @drawliin l’ha presa 42 giorni fa. Apertacmd:delete Priority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaEngineering Priority 1
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 2 giorni
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysForse già presa @greenlincoln05 l’ha presa 63 giorni fa. ApertaPriority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno