Skip to content

[BUG] npm incorrectly assumes existence of root-owned files on Termux #5114

Closed
@VoltrexKeyva

Description

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

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:

$ npm outdated -g
npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/ca13ccc3
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/43/a6/c7e13485e371db122c19f97a126c3d3a05e3f3050a79998bac598ab110422ff6ca2d65f0907caa47c66eb551785374e9216de04eae820a0f45c2c0cdd376
npm ERR! errno EACCES
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 ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2022-07-01T02_47_45_988Z-debug-0.log

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:

$ npm outdated -g
Package   Current  Wanted  Latest  Location               Depended by
corepack   0.10.0  0.11.2  0.11.2  node_modules/corepack  global

Steps To Reproduce

  1. Download, install, and launch Termux from it's official website.
  2. Update all installed packages by running apt update && apt upgrade -y.
  3. Install the latest Node.js LTS release (it doesn't have to be LTS, but for the sake of the example) which bundles npm as well by running apt install nodejs-lts -y.
  4. Update npm to v8.12.0 or higher by running npm i -g npm.
  5. Now try to install/update the global packages, it can also be local packages; for this step, try running npm update -g, and you'll encounter this error (some details may differ depending on your environment, but it's the same error):
npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/ca13ccc3
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/43/a6/c7e13485e371db122c19f97a126c3d3a05e3f3050a79998bac598ab110422ff6ca2d65f0907caa47c66eb551785374e9216de04eae820a0f45c2c0cdd376
npm ERR! errno EACCES
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 ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2022-07-01T02_47_45_988Z-debug-0.log

Environment

  • npm: v8.13.2
  • Node.js: v16.15.1
  • OS Name: Android 11
  • System Model Name: Galaxy A40 | SM-A405FN/DS
  • npm config:
; "user" config from /data/data/com.termux/files/home/.npmrc

//registry.npmjs.org/:_authToken = (protected)
foreground-scripts = true

; node bin location = /data/data/com.termux/files/usr/bin/node
; node version = v16.15.1
; npm local prefix = /data/data/com.termux/files/home
; npm version = 8.13.2
; cwd = /data/data/com.termux/files/home
; HOME = /data/data/com.termux/files/home
; Run `npm config ls -l` to show all defaults.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions