earendil-works/pi · error · Error

Project is not trusted; refusing to access project package…

Error message

Project is not trusted; refusing to access project package storage

What it means

Security guard in assertProjectTrustedForScope: an install/update operation targeted project scope (e.g. --local) but the project directory has not been marked trusted, so the manager refuses to read or write project package storage (which can execute extension code).

Solutions

  1. Trust the project when prompted or via settings before using project-scoped packages
  2. Install to user scope by omitting --local
  3. Review the project's extensions before trusting it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/core/package-manager.ts:1743 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/defda7c40bf90846. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/package-manager.ts:1743

				result[index] = entry;
			}
		}
		return result;
	}

	private parseNpmSpec(spec: string): { name: string; version?: string } {
		const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);
		if (!match) {
			return { name: spec };
		}
		const name = match[1] ?? spec;
		const version = match[2];
		return { name, version };
	}

	private assertProjectTrustedForScope(scope: SourceScope): void {
		if (scope === "project" && !this.settingsManager.isProjectTrusted()) {
			throw new Error("Project is not trusted; refusing to access project package storage");
		}
	}

	private getNpmCommand(): { command: string; args: string[] } {
		const configuredCommand = this.settingsManager.getNpmCommand();
		if (!configuredCommand || configuredCommand.length === 0) {
			return { command: "npm", args: [] };
		}
		const [command, ...args] = configuredCommand;
		if (!command) {
			throw new Error("Invalid npmCommand: first array entry must be a non-empty command");
		}
		return { command, args };
	}

	private getPackageManagerName(): string {
		const npmCommand = this.getNpmCommand();
		const commandParts = [npmCommand.command, ...npmCommand.args];

View on GitHub (pinned to 4af9d21d3b)