Skip to content
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

"run.sh" fails to install pnpm when not running as root #6822

Open
RalfJung opened this issue Jan 5, 2025 · 5 comments
Open

"run.sh" fails to install pnpm when not running as root #6822

RalfJung opened this issue Jan 5, 2025 · 5 comments

Comments

@RalfJung
Copy link

RalfJung commented Jan 5, 2025

Describe the bug
I am trying to update to etherpad 2.2.7 (current version is 1.9.7). Running run.sh fails with a permission error:

Jan 05 12:54:48 systemd[1]: Started etherpad-lite.service - etherpad-lite (real-time collaborative document editing).
Jan 05 12:54:49 run.sh[38599]: npm ERR! code EACCES
Jan 05 12:54:49 run.sh[38599]: npm ERR! syscall mkdir
Jan 05 12:54:49 run.sh[38599]: npm ERR! path /usr/local/lib/node_modules
Jan 05 12:54:49 run.sh[38599]: npm ERR! errno -13
Jan 05 12:54:49 run.sh[38599]: npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
Jan 05 12:54:49 run.sh[38599]: npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'] {
Jan 05 12:54:49 run.sh[38599]: npm ERR!   errno: -13,
Jan 05 12:54:49 run.sh[38599]: npm ERR!   code: 'EACCES',
Jan 05 12:54:49 run.sh[38599]: npm ERR!   syscall: 'mkdir',
Jan 05 12:54:49 run.sh[38599]: npm ERR!   path: '/usr/local/lib/node_modules'
Jan 05 12:54:49 run.sh[38599]: npm ERR! }
Jan 05 12:54:49 run.sh[38599]: npm ERR!
Jan 05 12:54:49 run.sh[38599]: npm ERR! The operation was rejected by your operating system.
Jan 05 12:54:49 run.sh[38599]: npm ERR! It is likely you do not have the permissions to access this file as the current user

I suspect this is npm install pnpm -g failing. Apparently it tries to write to /usr. The run.sh script itself bails out when running as root, so it seems like the logic in installDeps.sh that installs pnpm doesn't seem to make a lot of sense?

To Reproduce
Steps to reproduce the behavior:

  1. Run run.sh on a system without pnpm installed.

Expected behavior
Etherpad should start up successfully.

Server (please complete the following information):

  • Etherpad version: 2.2.7
  • OS: Debian 12
  • Node.js version (node --version): v18.19.0
  • npm version (npm --version): 9.2.0

Additional context
I will definitely not run npm as root, so I am currently unsure how I could install pnpm. Somehow it should be installed only for the user that runs etherpad.

@SamTV12345
Copy link
Member

Hey. There is also some extra possibilities how to install pnpm https://pnpm.io/installation . You could use corepack for this.

@RalfJung
Copy link
Author

Is there a way to use npm install without -g and just install something for the local user? Something like pip install --local or cargo install, neither of which need root permissions.

I am not a nodejs/npm user myself so it's quite hard to figure this out based on just the etherpad docs.

@SamTV12345
Copy link
Member

it is probably sufficient if you add pnpm in your user folder. Or when Etherpad is installed locally just go to the install folder and do npm i pnpm which will install pnpm in Etherpad only.

@RalfJung
Copy link
Author

I tried adding this to the service file

ExecStartPre=/bin/bash -c "which pnpm || npm install pnpm"

That fails with a completely inscrutable error message:

npm ERR! Tracker "idealTree" already exists
npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/nodejs/.npm/_logs/2025-02-14T07_54_16_677Z-debug-0.log

Searching for this online brings many mentions of docker/podman, and suggests to use -g, but running sudo npm is clearly a bad idea so that doesn't sound like a proper solution.

@RalfJung
Copy link
Author

RalfJung commented Feb 14, 2025

Ah, I missed the "go to the install folder"... I don't know why npm install would care about my working directory when trying to install pnpm from the package registry (i.e., not a local package) but 🤷 that does lead to a different error message at least:

537 verbose stack Error: Unsupported URL Type "workspace:": workspace:./src
537 verbose stack     at unsupportedURLType (/usr/share/nodejs/npm-package-arg/lib/npa.js:301:15)
537 verbose stack     at fromURL (/usr/share/nodejs/npm-package-arg/lib/npa.js:361:13)
537 verbose stack     at Function.resolve (/usr/share/nodejs/npm-package-arg/lib/npa.js:82:12)
537 verbose stack     at [nodeFromEdge] (/usr/share/nodejs/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1057:22)
537 verbose stack     at [buildDepStep] (/usr/share/nodejs/@npmcli/arborist/lib/arborist/build-ideal-tree.js:928:36)
537 verbose stack     at [buildDeps] (/usr/share/nodejs/@npmcli/arborist/lib/arborist/build-ideal-tree.js:775:31)
537 verbose stack     at Arborist.buildIdealTree (/usr/share/nodejs/@npmcli/arborist/lib/arborist/build-ideal-tree.js:206:29)
537 verbose stack     at async Promise.all (index 1)
537 verbose stack     at async Arborist.reify (/usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:156:5)
537 verbose stack     at async Install.exec (/usr/share/nodejs/npm/lib/commands/install.js:146:5)
538 verbose cwd /srv/pad.ralfj.de/etherpad-lite
539 verbose Linux 6.1.0-31-amd64
540 verbose node v18.19.0
541 verbose npm  v9.2.0
542 error code EUNSUPPORTEDPROTOCOL
543 error Unsupported URL Type "workspace:": workspace:./src
544 verbose exit 1

If I understand this correctly, the fix here is to use pnpm instead of npm, but this occurs while trying to install pnpm... classic dependency loop.^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants