-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm incorrectly assumes existence of root-owned files on Termux #5114
Comments
I am having the same error prompt when i do |
Same! I thought I'm the only one having this issue. I have a Samsung A50S, npm v8.13.2, v18.4.0, also using Termux.
|
Ok so after doing $ pkg uninstall nodejs And run $ pkg install nodejs-lts It worked fine. No idea how. |
That's because reinstalling Node.js replaces the currently installed npm with the one shipped with that Node.js binary, as of writing this, the current Node.js LTS release from the Termux repositories ship npm v18.11.x which this issue isn't present in. As mentioned, this issue has been occurring since v8.12.0. |
this actually has nothing to do with root ownership, the error messaging there is not great. any EACCES or EPERM error relating to your cache directory triggers this exact warning. do you have write access to the cache directory? what filesystem is it? can one of you seeing this problem post the full debug log here? |
In my case I have full write access to the npm cache directory, if I didn't then any npm version older than 8.12.0 would've also failed with the same error, which they don't. I don't think the type of file system is relevant here but my device's file system type is ext4. The debug log: $ npm update -g --verbose Debug lognpm verb cli /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/usr/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 2ms
npm timing config:load:defaults Completed in 11ms
npm timing config:load:file:/data/data/com.termux/files/usr/lib/node_modules/npm/npmrc Completed in 27ms
npm timing config:load:builtin Completed in 28ms
npm timing config:load:cli Completed in 16ms
npm timing config:load:env Completed in 3ms
npm timing config:load:project Completed in 21ms
npm timing config:load:file:/data/data/com.termux/files/home/.npmrc Completed in 7ms
npm timing config:load:user Completed in 9ms
npm timing config:load:file:/data/data/com.termux/files/usr/etc/npmrc Completed in 1ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 5ms
npm timing config:load:setEnvs Completed in 6ms
npm timing config:load Completed in 107ms
npm timing npm:load:configload Completed in 109ms
npm timing npm:load:mkdirpcache Completed in 5ms
npm timing npm:load:mkdirplogs Completed in 3ms
npm verb title npm update
npm verb argv "update" "--global" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 7ms
npm timing config:load:flatten Completed in 17ms
npm timing npm:load:display Completed in 45ms
npm verb logfile logs-max:10 dir:/data/data/com.termux/files/home/.npm/_logs
npm verb logfile /data/data/com.termux/files/home/.npm/_logs/2022-07-13T23_20_12_621Z-debug-0.log
npm timing npm:load:logFile Completed in 33ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 1ms
npm timing npm:load Completed in 214ms
npm timing arborist:ctor Completed in 4ms
npm timing idealTree:init Completed in 30ms
npm timing idealTree:userRequests Completed in 14ms
npm http fetch GET 200 https://registry.npmjs.org/corepack 1535ms (cache updated)
npm http fetch GET 200 https://registry.npmjs.org/npm 1504ms (cache updated)
npm timing idealTree:#root Completed in 3116ms
npm timing idealTree:node_modules/corepack Completed in 0ms
npm timing idealTree:node_modules/npm Completed in 0ms
npm timing idealTree:buildDeps Completed in 3124ms
npm timing idealTree:fixDepFlags Completed in 4ms
npm timing idealTree Completed in 3184ms
npm timing command:update Completed in 3245ms
npm verb type system
npm verb stack FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/corepack: EACCES: permission denied, link '/data/data/com.termux/files/home/.npm/_cacache/tmp/ecbbb0fd' -> '/data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7'
npm verb stack at /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15
npm verb stack at async RegistryFetcher.packument (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25)
npm verb stack at async RegistryFetcher.manifest (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
npm verb stack at async Arborist.[nodeFromEdge] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19)
npm verb stack at async Arborist.[buildDepStep] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11)
npm verb stack at async Arborist.buildIdealTree (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
npm verb stack at async Arborist.reify (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:5)
npm verb stack at async Update.exec (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/commands/update.js:65:5)
npm verb stack at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/cli.js:78:5)
npm verb cwd /data/data/com.termux/files/home
npm verb Linux 4.4.177-24085844
npm verb node v16.15.1
npm verb npm v8.13.2
npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/ecbbb0fd
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7
npm ERR! errno EACCES
npm verb FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/corepack: EACCES: permission denied, link '/data/data/com.termux/files/home/.npm/_cacache/tmp/ecbbb0fd' -> '/data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7'
at /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15
at async RegistryFetcher.packument (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25)
at async RegistryFetcher.manifest (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
at async Arborist.[nodeFromEdge] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19)
at async Arborist.[buildDepStep] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11)
at async Arborist.buildIdealTree (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
at async Arborist.reify (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:5)
at async Update.exec (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/commands/update.js:65:5)
at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/cli.js:78:5)
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 10272:10272 "/data/data/com.termux/files/home/.npm"
npm verb exit 1
npm timing npm Completed in 3842ms
npm verb unfinished npm timer reify 1657754413199
npm verb unfinished npm timer reify:loadTrees 1657754413245
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! /data/data/com.termux/files/home/.npm/_logs/2022-07-13T23_20_12_621Z-debug-0.log Debug log for the newer npm v8.15.0 releasenpm verb cli /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/usr/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 1ms
npm timing config:load:defaults Completed in 9ms
npm timing config:load:file:/data/data/com.termux/files/usr/lib/node_modules/npm/npmrc Completed in 13ms
npm timing config:load:builtin Completed in 14ms
npm timing config:load:cli Completed in 13ms
npm timing config:load:env Completed in 2ms
npm timing config:load:project Completed in 11ms
npm timing config:load:file:/data/data/com.termux/files/home/.npmrc Completed in 9ms
npm timing config:load:user Completed in 9ms
npm timing config:load:file:/data/data/com.termux/files/usr/etc/npmrc Completed in 9ms
npm timing config:load:global Completed in 10ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 6ms
npm timing config:load:setEnvs Completed in 5ms
npm timing config:load Completed in 85ms
npm timing npm:load:configload Completed in 86ms
npm timing npm:load:mkdirpcache Completed in 5ms
npm timing npm:load:mkdirplogs Completed in 1ms
npm verb title npm update
npm verb argv "update" "--global" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 6ms
npm timing config:load:flatten Completed in 16ms
npm timing npm:load:display Completed in 42ms
npm verb logfile logs-max:10 dir:/data/data/com.termux/files/home/.npm/_logs
npm verb logfile /data/data/com.termux/files/home/.npm/_logs/2022-07-21T13_52_24_138Z-debug-0.log
npm timing npm:load:logFile Completed in 32ms
npm timing npm:load:timers Completed in 1ms
npm timing npm:load:configScope Completed in 1ms
npm timing npm:load Completed in 183ms
npm timing arborist:ctor Completed in 6ms
npm timing idealTree:init Completed in 34ms
npm timing idealTree:userRequests Completed in 16ms
npm http fetch GET 200 https://registry.npmjs.org/corepack 1853ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/npm 1921ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/prettier 685ms (cache miss)
npm timing idealTree:#root Completed in 4593ms
npm timing idealTree:node_modules/corepack Completed in 0ms
npm timing idealTree:node_modules/npm Completed in 0ms
npm timing idealTree:node_modules/prettier Completed in 0ms
npm timing idealTree:buildDeps Completed in 4606ms
npm timing idealTree:fixDepFlags Completed in 7ms
npm timing idealTree Completed in 4673ms
npm timing command:update Completed in 4771ms
npm verb type system
npm verb stack FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/corepack: EACCES: permission denied, link '/data/data/com.termux/files/home/.npm/_cacache/tmp/9b99c620' -> '/data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7'
npm verb stack at /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15
npm verb stack at async RegistryFetcher.packument (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25)
npm verb stack at async RegistryFetcher.manifest (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
npm verb stack at async Arborist.[nodeFromEdge] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19)
npm verb stack at async Arborist.[buildDepStep] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11)
npm verb stack at async Arborist.buildIdealTree (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
npm verb stack at async Arborist.reify (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
npm verb stack at async Update.exec (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/commands/update.js:65:5)
npm verb stack at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/cli.js:78:5)
npm verb cwd /data/data/com.termux/files/home
npm verb Linux 4.4.177-24392161
npm verb node v16.15.1
npm verb npm v8.15.0
npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/9b99c620
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7
npm ERR! errno EACCES
npm verb FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/corepack: EACCES: permission denied, link '/data/data/com.termux/files/home/.npm/_cacache/tmp/9b99c620' -> '/data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/8b/29/d8d04509b38b390ebcba4956b8fb2955f88570f48241edffb01128b2dcdfb4580c453db04a422a8046fb9fdf7c7c9c31a25a64ac280c8f7892511b0798a7'
at /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15
at async RegistryFetcher.packument (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25)
at async RegistryFetcher.manifest (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
at async Arborist.[nodeFromEdge] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19)
at async Arborist.[buildDepStep] (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11)
at async Arborist.buildIdealTree (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
at async Arborist.reify (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
at async Update.exec (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/commands/update.js:65:5)
at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/npm/lib/cli.js:78:5)
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 10272:10272 "/data/data/com.termux/files/home/.npm"
npm verb exit 1
npm timing npm Completed in 5446ms
npm verb unfinished npm timer reify 1658411544793
npm verb unfinished npm timer reify:loadTrees 1658411544869
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! /data/data/com.termux/files/home/.npm/_logs/2022-07-21T13_52_24_138Z-debug-0.log |
@nlf any updates on this? |
@VoltrexMaster just doing |
This is not an actual fix for the issue at hand, doing that just uninstalls Node.js, and reinstalling Node.js will install an older version of npm (v8.11.x) where this issue is not present. The error I've denoted in my issue started occuring since npm v8.12.x which is still not fixed even in npm v8.15.x. |
The solution that worked for me was to set the cache location for npm like so: |
In this case, npm does have full access to the default cache directory which is located in I suspect there is an issue with Arborist which causes this issue, although I'm not familiar with it's codebase so I'm unsure what exactly causes this issue. |
npm ERR! errno EACCES |
Do somebody have the idea of solving this...permanently?
|
This is shown with npm v |
same issue, i can't even downgrade |
@griffi-gh did u do |
yep, node reinstall downgrades npm. |
@griffi-gh happy debugging then ;) |
any update on this? still facing this issue |
Yes, this is still an issue.
It seems |
for github-actions, i worked around this issue by but it's still annoying and not a pretty solution.. |
This can't be solved by any of the ways formulated above. Only solution I have found is just by avoiding it by changing npm version. Current release of npm is 9.0.1. Follow the commands |
I aint facing this problem anymore. I just did normal installation using u0_a260@localhost ~ (main) [1]> npm outdated -g
Package Current Wanted Latest Location Depended by
@tailwindcss/language-server 0.0.9 0.0.10 0.0.10 node_modules/@tailwindcss/language-server global
corepack 0.14.1 0.15.0 0.15.0 node_modules/corepack global
u0_a260@localhost ~ (main) [1]> |
This issue no longer occurs after the Node.js runtime was updated to v16.18.0 in the Termux repositories, closing. |
Nope, still is an issue for me.
|
It's another issue |
|
root@host:/var/www/mycloud.com/apps/recognize# sudo -u www-data make npm ERR! Log files were not written due to an error writing to the directory: /var/www/.npm/_logs
|
This is now happening on the 9.1.2 version:
Can't solve with sudo since I don't have root |
November 29th, installing Termux on a new device and was introduced to this thread. Still a problem. I tried the solution above of changing the /tmp directory from GamerCreator, and it just decided to balk about the new directory still. |
Most up-to-date information we have about this: termux/termux-packages#13293 |
related issue on NPM: npm/cli#5114 (comment)
related issue on NPM: npm/cli#5114 (comment)
Note: The branch name is created without a # in the front, to test my build and deployments from my local. - [x] Investigate the issue and apply the fix on all our custom Dockerfile (Api, web, workers, queue-consumers, load-test-gateway & db-migration) - [x] Most updated image in node has to be deployed What does EACCES error means in node - https://betterstack.com/community/guides/scaling-nodejs/nodejs-errors/#13-eacces On Analysing the issue, i was able to understand that this issue happens in certain version of node & npm libraries, some related bugs reported in the years are given below for reference. - npm/cli#5114 - https://stackoverflow.com/questions/71450392/npm-cache-issue - https://stackoverflow.com/questions/67163194/jenkins-build-issue-npm-err-your-cache-folder-contains-root-owned-files The possible solutions given by the people are alwauys these 2 - give sudo permission and access for the user 1001 for the /.npm directory/ - which is not always right to have a sudo persmission for a user in dockerfile - upgrade the node version as it states to a newer version that this issue is not happening - going with this route as we have a newer version of redhat that contains the new version from the one deplyoed already with some security issues. https://catalog.redhat.com/software/containers/ubi8/nodejs-18/6278e5c078709f5277f26998?architecture=amd64&image=65302e01ec5935b621691d22&container-tabs=packages ![image](https://github.com/bcgov/SIMS/assets/62901416/1f7136b4-3daf-43d3-9af3-6232865be1e3) https://catalog.redhat.com/software/containers/ubi8/nodejs-18/6278e5c078709f5277f26998?architecture=amd64&image=6543c3d67371c4bd3014291a&container-tabs=packages <img width="1290" alt="image" src="https://github.com/bcgov/SIMS/assets/62901416/a492658d-bd7f-4a92-9513-2b26038a475c"> Analyzing the changelogs of npm js, there has been bugs related to cache that has been fixed. https://docs.npmjs.com/cli/v9/using-npm/changelog#981-2023-07-18 https://docs.npmjs.com/cli/v9/using-npm/changelog#967-2023-05-17 ![image](https://github.com/bcgov/SIMS/assets/62901416/e35782a3-28f3-4c5c-982b-58b06ac6404b) npm/cli#6464 The bug reported may not state the same issue we are facing but its related to the cache error that is happening in the version we were using. So updating the redhat image to the latest version is what was taken as an action to solve this issue. Note: https://app.zenhub.com/workspaces/student-information-management-system-5fce9df5aa1b45000e937014/issues/gh/bcgov/sims/2453 is also done as part of this PR. - [x] Remove variables from Makefile - [x] Remove references from docker-build.yml As suggested by @andrewsignori-aot #2577 (comment) changed the permission of users in the group 0 for the folder ./.npm to have write access Container before assigning the write permission <img width="889" alt="image" src="https://github.com/bcgov/SIMS/assets/62901416/a8d95861-d538-4661-9e6c-429b30f2f6e3"> Container after assigning the write permission <img width="740" alt="image" src="https://github.com/bcgov/SIMS/assets/62901416/2343b44b-2b4b-4849-8f55-084beea91d0b"> Addded only the permissions for the ./.npm folder as in the past month the failed logs show this error happening only in the ./.npm folder. https://kibana-openshift-logging.apps.silver.devops.gov.bc.ca/app/kibana#/discover?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-30d,mode:quick,to:now))&_a=(columns:!(message),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'8841c680-a15b-11eb-a4dc-e5bf19f04239',key:kubernetes.namespace_name,negate:!f,params:(query:'0c27fb-test',type:phrase),type:phrase,value:'0c27fb-test'),query:(match:(kubernetes.namespace_name:(query:'0c27fb-test',type:phrase))))),index:'8841c680-a15b-11eb-a4dc-e5bf19f04239',interval:auto,query:(language:lucene,query:'%22sudo%20chown%20-R%20%22'),sort:!('@timestamp',desc)) <img width="923" alt="image" src="https://github.com/bcgov/SIMS/assets/62901416/ba796f55-5447-4c4a-9fef-aba1ab129d5c">
I'm creating a react app on openshift, but after deployment of pod when i "rsh" into container shell and try to run "npm start" i'm getting above error. $ ls -l /.npm |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
On Termux, npm seems to incorrectly assume the existence of files owned by root in the
.npm
directory when trying to either check the outdated global packages, installing a package, or updating a package; nothing in Termux is root-owned by default (and your device must be rooted to even have anything owned by root).This behavior has started occurring since npm v8.12.0.
Example:
As mentioned, this can also occur when trying to install or update a package (doesn't matter if it's global or local).
Some others seems to be experiencing the same issue: #5025, and #4451 (comment)
Expected Behavior
The expected behavior is for npm to work without assuming the existence of root-owned files that doesn't actually exist, basically to not throw the aforementioned error when checking for outdated global packages, installing/updating global or local packages.
Example:
Steps To Reproduce
apt update && apt upgrade -y
.apt install nodejs-lts -y
.npm i -g npm
.npm update -g
, and you'll encounter this error (some details may differ depending on your environment, but it's the same error):Environment
The text was updated successfully, but these errors were encountered: