diff --git a/nanoclaw.sh b/nanoclaw.sh index 0bf193873..f8b58e7cb 100755 --- a/nanoclaw.sh +++ b/nanoclaw.sh @@ -245,6 +245,17 @@ fi # wipe it. export NANOCLAW_BOOTSTRAPPED=1 +# setup.sh may have just installed pnpm via npm into a prefix that's not on +# our PATH (custom `npm config set prefix`, or the default prefix missing +# from the shell's login PATH). Its PATH mutation doesn't propagate back +# to us — so replay the same lookup here before the exec. +if ! command -v pnpm >/dev/null 2>&1 && command -v npm >/dev/null 2>&1; then + NPM_PREFIX="$(npm config get prefix 2>/dev/null)" + if [ -n "$NPM_PREFIX" ] && [ -x "$NPM_PREFIX/bin/pnpm" ]; then + export PATH="$NPM_PREFIX/bin:$PATH" + fi +fi + # --silent suppresses pnpm's `> nanoclaw@2.0.0 setup:auto / > tsx setup/auto.ts` # preamble so the flow continues visually from "Basics installed" straight # into setup:auto's spinner. exec so signals (Ctrl-C) propagate directly. diff --git a/setup.sh b/setup.sh index e11e073e1..9ca73c1bb 100755 --- a/setup.sh +++ b/setup.sh @@ -120,6 +120,20 @@ install_deps() { || true fi + # `npm install -g` writes to npm's global prefix, which isn't always on the + # shell PATH — common on macOS where the user has `npm config set prefix + # ~/.npm-global` to avoid sudo, or on Linux where /usr/local/bin isn't in + # PATH. Discover the prefix and prepend its bin dir so `command -v pnpm` + # sees the new install. + if ! command -v pnpm >/dev/null 2>&1 && command -v npm >/dev/null 2>&1; then + local npm_prefix + npm_prefix=$(npm config get prefix 2>/dev/null) + if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/pnpm" ]; then + export PATH="$npm_prefix/bin:$PATH" + log "Prepended npm prefix bin to PATH: $npm_prefix/bin" + fi + fi + if ! command -v pnpm >/dev/null 2>&1; then log "pnpm not on PATH after corepack + npm fallback" return