I’m writing this post because I’m facing a strange error with buildNpmPackage that doesn’t seem to be documented anywhere.
When trying to build the attached flake, in fact, NPM fails with the following error:
npm ERR! path /nix/store/lygyvacyjpmfsji3ym4n4d2wi4fxc0h5-antares-v0.7.9-npm-deps/_cacache/tmp
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:100 "/nix/store/lygyvacyjpmfsji3ym4n4d2wi4fxc0h5-antares-v0.7.9-npm-deps"
npm ERR! Log files were not written due to an error writing to the directory: /nix/store/lygyvacyjpmfsji3ym4n4d2wi4fxc0h5-antares-v0.7.9-npm-deps/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Personally, I find this pretty puzzling, as (citing the nixpkgs manual) “buildNpmPackage allows you to package npm-based projects in Nixpkgs without the use of an auto-generated dependencies files […] by […] creating a reproducible cache that contains the dependencies of a project, and pointing npm to it”, which makes links to the root-owned Nix Store expected.
Can someone point me to what I’ve done wrong in writing the derivation? Thank you very much in advance!
Just ran into this as well. A bit more log context, in case it helps:
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/lsw181y0h0b1sb63gmz2c41f0allk39f-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
Executing npmConfigHook
Configuring npm
Validating consistency between /build/source/package-lock.json and /nix/store/30k9hk6f57h7bwlbd4jp749yhxmval0b-lean4web-npm-deps/package-lock.json
Installing dependencies
npm WARN tarball cached data for lean4@https://gitpkg.now.sh/leanprover/vscode-lean4/vscode-lean4?8d0cc34dcfa00da8b4a48394ba1fb3a600e3f985 (sha512-hA7bb0EFlNwtk7+/7gO5OZS7HtrhmoRacE/b2etFBYG4>
npm ERR! code EACCES
npm ERR! syscall unlink
npm ERR! path /nix/store/30k9hk6f57h7bwlbd4jp749yhxmval0b-lean4web-npm-deps/_cacache/content-v2/sha512/84/0e/db6f410594dc2d93bfbfee03b93994bb1edae19a845a704fdbd9eb450581b815b91977f34a4dcb393c>
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:100 "/nix/store/30k9hk6f57h7bwlbd4jp749yhxmval0b-lean4web-npm-deps"
npm ERR! Log files were not written due to an error writing to the directory: /nix/store/30k9hk6f57h7bwlbd4jp749yhxmval0b-lean4web-npm-deps/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Hmm, some combination of running nix run nixpkgs#nodejs -- npm install --package-lock-only and updating that repository somehow fixed it, and I can’t easily reproduce it now. I’ll try to share a reproducer when I encounter it again!