proot icon indicating copy to clipboard operation
proot copied to clipboard

Npm not working in proot with debian trixie

Open supastishn opened this issue 1 year ago • 2 comments

Problem description

The issue is that, with most packages, attempting to install will give a cache error similar to:


│  npm WARN tarball tarball data for locate-path@https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz (sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==) seems to be corrupted. Trying again.
│  npm WARN tarball tarball data for dequal@https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz (sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==) seems to be corrupted. Trying again.                                                                                                         │  npm WARN tarball tarball data for locate-path@https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz (sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==) seems to be corrupted. Trying again.                                                                                          │  npm WARN tarball tarball data for dequal@https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz (sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==) seems to be corrupted. Trying again.
│  npm ERR! code ENOENT
│  npm ERR! syscall rename                                                                                                                                              │  npm ERR! path /home/supastishn/.npm/_cacache/tmp/0cc23c35
│  npm ERR! dest /home/supastishn/.npm/_cacache/content-v2/sha512/88/f6/4ae9e6236f146edee078fd667712c10830914ca80a28a65dd1fb3baad148dc026fcc3ba282c1e0e03df3f77a54f3b6828fdcab67547c539f63470520d553
│  npm ERR! errno -2
│  npm ERR! enoent ENOENT: no such file or directory, rename '/home/supastishn/.npm/_cacache/tmp/0cc23c35' -> '/home/supastishn/.npm/_cacache/content-v2/sha512/88/f6/4ae9e6236f146edee078fd667712c10830914ca80a28a65dd1fb3baad148dc026fcc3ba282c1e0e03df3f77a54f3b6828fdcab67547c539f63470520d553'
│  npm ERR! enoent This is related to npm not being able to find a file.
│  npm ERR! enoent
│
│  npm ERR! A complete log of this run can be found in:
│  npm ERR!     /home/supastishn/.npm/_logs/2025-09-24T18_14_25_736Z-debug-0.log
│
└  Operation failed.

Steps to reproduce

  1. Login to Debian Trixie via proot distro (note: i was told to report error here instead of proot-distro repo)
  2. Install NPM
  3. Do something requiring installing dependencies like npx http-server, or npm create vite@latest

Expected behavior

For it to properly install dependencies.

Additional information

Termux Variables:
unsupported
Packages CPU architecture:
arm64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main/ stable main
Updatable packages:
base-files/stable 13.8+deb13u1 arm64 [upgradable from: 13.8]
init-system-helpers/stable 1.69~deb13u1 all [upgradable from: 1.68]
libpcre2-8-0/stable 10.46-1~deb13u1 arm64 [upgradable from: 10.45-1]
linux-libc-dev/stable-security 6.12.48-1 all [upgradable from: 6.12.43-1]
tzdata/stable 2025b-4+deb13u1 all [upgradable from: 2025b-4]
termux-tools version:
1.45.0
Android version:
14
Kernel build information:
Linux localhost 6.2.1-PRoot-Distro #1 SMP PREEMPT Thu Feb 13 13:44:36 UTC 2025 aarch64 GNU/Linux
Device manufacturer:
Xiaomi
Device model:
23043RP34G
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=
Installed termux plugins:
com.termux.api versionCode:1000
com.termux.x11 versionCode:15
com.termux.styling versionCode:1000

supastishn avatar Sep 24 '25 18:09 supastishn

+1

RohitKushvaha01 avatar Oct 30 '25 05:10 RohitKushvaha01

I've encountered a related but distinct failure mode on Android 13 (aarch64), proot 5.1.0, proot-distro Ubuntu 25.10, Node.js v20.

Symptom: npm install hangs indefinitely rather than failing with an error. The process never produces output and must be killed.

Investigation:

Checking /proc/PID/status while npm is hung shows state t (tracing stop) — the process is stuck waiting for proot to resume it from a ptrace stop that never resolves.

The hang point is non-deterministic: it occurs at different points in module loading on different runs (sometimes cacache, sometimes tar, sometimes another module), suggesting a race condition rather than a deterministic syscall translation failure.

Minimal reproduction:

# This intermittently hangs inside proot Ubuntu (~50% of runs):
node -e "require('/usr/lib/node_modules/npm/node_modules/cacache'); process.exit(0)"

# This is consistently fine:
echo "require('/usr/lib/node_modules/npm/node_modules/cacache'); process.exit(0)" > /tmp/t.js
node /tmp/t.js

Hypothesis:

Node.js v20 spawns a libuv thread pool (typically 4 threads) at startup. Each thread makes syscalls independently. Since proot's event loop is single-threaded (processes one waitpid event at a time), if two threads reach a ptrace stop simultaneously and the resolution of one depends on the other, proot can deadlock — it unblocks them serially but the ordering may cause a dependency cycle.

The -e vs file execution difference may relate to slightly different thread startup timing, making the race more or less likely to trigger.

Workaround:

Run npm from native Termux (not proot) using npm install -g for any packages needed inside proot, then symlink or copy them into the proot rootfs. Or pre-install packages on a Linux machine and copy node_modules in.

Related: upstream proot issue #111 (multi-threading support), proot-me/proot #77 (multi-threaded ptrace).

daniel-thisnow avatar Mar 03 '26 21:03 daniel-thisnow