Skip to content

pi tries to install npm extensions system global on Linux instead of the .pi folder #4587

@imrehg

Description

@imrehg

What happened?

When running pi install <npm-hosted-extension> Pi tries to install the packages globally, and on Linux systems likely fails with access error (trying to install to /usr/lib/node_modules/...:

$ pi install npm:pi-simplify
Installing npm:pi-simplify...
npm error code EACCES
npm error syscall mkdir
npm error path /usr/lib/node_modules/pi-simplify
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/pi-simplify'
npm error     at async mkdir (node:internal/fs/promises:1501:10)
npm error     at async /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:589:20
npm error     at async Promise.allSettled (index 0)
npm error     at async #reifyPackages (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:321:11)
npm error     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:127:5)
npm error     at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:149:5)
npm error     at async Npm.exec (/usr/lib/node_modules/npm/lib/npm.js:193:9)
npm error     at async module.exports (/usr/lib/node_modules/npm/lib/cli/entry.js:67:5) {
npm error   errno: -13,
npm error   code: 'EACCES',
npm error   syscall: 'mkdir',
npm error   path: '/usr/lib/node_modules/pi-simplify'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the permissions of the file and its containing directories, or try running the command again as root/Administrator.
npm error A complete log of this run can be found in: /home/greg/.npm/_logs/2026-05-16T15_37_35_967Z-debug-0.log
Error: npm install -g pi-simplify failed with code 243

The relevant code is here:

private async installNpmBatch(specs: string[], scope: InstalledSourceScope): Promise<void> {
if (scope === "user") {
await this.runNpmCommand(["install", "-g", ...specs]);
return;
}
const installRoot = this.getNpmInstallRoot(scope, false);
this.ensureNpmProject(installRoot);
await this.runNpmCommand(["install", ...specs, "--prefix", installRoot]);
}

Steps to reproduce

  1. EDIT to add: install the pi-coding-agent on ArchLinux
  2. on Linux, try to install an npm module for pi, such as npm:pi-simplify as a normal user, with pi install npm:pi-simplify
  3. see the access error

Expected behavior

The docs say the extension location is in ~/.pi/agent/extensions/... when things installed on the user level, so pi install installs the extension into the .pi/agent/... folder. Similar stuff with packages are defined as the packages: [...] in ~/.pi/agent/settings.json.

Version

0.74.0

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions