diff --git a/.claude/skills/new-setup/SKILL.md b/.claude/skills/new-setup/SKILL.md index 4c2a1fe..2a92b58 100644 --- a/.claude/skills/new-setup/SKILL.md +++ b/.claude/skills/new-setup/SKILL.md @@ -28,13 +28,18 @@ If the probe reports `STATUS: unavailable` (Node isn't installed yet), ignore al ### 1. Node bootstrap -Always runs — probe can't report on this since it lives below the Node layer. - > *"Now I'm installing Node and your project's dependencies, so the rest of setup has what it needs to run."* -Run `bash setup.sh`. Parse the status block. +If the probe reported `STATUS: unavailable` (Node isn't installed yet), install Node 22 **before** running `bash setup.sh` — otherwise the first bootstrap run is guaranteed to fail and you'll pay for it twice: -- `NODE_OK=false` → Offer to install Node 22 (macOS: `brew install node@22`; Linux: `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs`). Re-run. +- macOS: `brew install node@22` +- Linux / WSL: `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs` + +Then run `bash setup.sh`. If the probe reported any other status, run `bash setup.sh` directly — it's idempotent and verifies host deps + native modules. + +Parse the status block: + +- `NODE_OK=false` → Node install didn't take effect (PATH issue, keg-only formula, etc.). Investigate `logs/setup.log`, resolve, re-run. - `DEPS_OK=false` or `NATIVE_OK=false` → Read `logs/setup.log`, fix, re-run. > **Loose command:** `bash setup.sh`. Justification: pre-Node bootstrap. Can't call the Node-based dispatcher before Node and `pnpm install` are in place. diff --git a/setup.sh b/setup.sh index fb69d0a..af2c5e5 100755 --- a/setup.sh +++ b/setup.sh @@ -72,10 +72,21 @@ install_deps() { cd "$PROJECT_ROOT" - # Enable corepack for pnpm + # Enable corepack so `pnpm` shim lands on PATH. log "Enabling corepack" corepack enable >> "$LOG_FILE" 2>&1 || true + # On Linux/WSL with system-wide Node (e.g. apt-installed to /usr/bin), + # corepack needs root to symlink /usr/bin/pnpm. Retry with sudo when pnpm + # isn't on PATH. macOS Homebrew installs land in a user-writable prefix, + # and a sudo retry there would create root-owned shims inside /opt/homebrew + # that later break brew — so the retry is Linux-only. + if ! command -v pnpm >/dev/null 2>&1 && [ "$PLATFORM" = "linux" ] \ + && command -v sudo >/dev/null 2>&1; then + log "pnpm not on PATH after corepack enable — retrying with sudo" + sudo corepack enable >> "$LOG_FILE" 2>&1 || true + fi + log "Running pnpm install --frozen-lockfile" if pnpm install --frozen-lockfile >> "$LOG_FILE" 2>&1; then DEPS_OK="true"