From 954f3b48939fa95befe5d773e47897bb4e88c170 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Wed, 25 Feb 2026 21:57:09 -0800 Subject: [PATCH] fix: use user-local npm prefix for openclaw install (#1941) npm install -g openclaw fails with EACCES on non-root users (e.g., ubuntu on AWS Lightsail) because /usr/local/lib/node_modules isn't writable. Use the same ~/.npm-global prefix pattern already used by codex and kilocode agents. Fixes both the standard installAgent path and the batched setupOpenclawBatched path (used by Fly). Co-authored-by: spawn-bot Co-authored-by: Claude Opus 4.6 --- packages/cli/package.json | 2 +- packages/cli/src/shared/agent-setup.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 23ce8a64..be9f2323 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/spawn", - "version": "0.10.17", + "version": "0.10.18", "type": "module", "bin": { "spawn": "cli.js" diff --git a/packages/cli/src/shared/agent-setup.ts b/packages/cli/src/shared/agent-setup.ts index c45bb8b2..e072dd7f 100644 --- a/packages/cli/src/shared/agent-setup.ts +++ b/packages/cli/src/shared/agent-setup.ts @@ -327,12 +327,13 @@ export async function setupOpenclawBatched( const script = [ 'echo "==> Checking openclaw..."', - 'export PATH="$HOME/.bun/bin:$HOME/.local/bin:$PATH"', + 'export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$PATH"', "if command -v openclaw >/dev/null 2>&1; then", ' echo " openclaw found at $(command -v openclaw)"', "else", ' echo " openclaw not found, installing..."', - " npm install -g openclaw", + " mkdir -p ~/.npm-global/bin && npm config set prefix ~/.npm-global && npm install -g openclaw", + ' export PATH="$HOME/.npm-global/bin:$PATH"', ' command -v openclaw || { echo "ERROR: openclaw install failed"; exit 1; }', "fi", 'echo "==> Writing environment variables..."', @@ -475,7 +476,12 @@ export function createAgents(runner: CloudRunner): Record { cloudInitTier: "full", modelPrompt: true, modelDefault: "openrouter/auto", - install: () => installAgent(runner, "openclaw", "source ~/.bashrc && npm install -g openclaw"), + install: () => + installAgent( + runner, + "openclaw", + "source ~/.bashrc && mkdir -p ~/.npm-global/bin && npm config set prefix ~/.npm-global && npm install -g openclaw", + ), envVars: (apiKey) => [ `OPENROUTER_API_KEY=${apiKey}`, `ANTHROPIC_API_KEY=${apiKey}`,