fix(bootstrap): unify npm-global PATH snippet into one shared file #130

Merged
clawdie merged 1 commit from fix/unify-npm-profile-snippet into main 2026-06-21 16:22:39 +02:00
2 changed files with 24 additions and 9 deletions

View file

@ -83,16 +83,13 @@ if [ ! -e "${NPM_PREFIX}/bin/pi" ]; then
fi
cp -a "${NPM_PREFIX}/bin/pi" "${JAIL_ROOT}${NPM_PREFIX}/bin/pi"
# Put the npm-global bin on PATH for every login shell. Canonical mechanism
# (same shape as the clawdie-iso image): the PATH content lives in one managed
# /etc/profile.d snippet derived from NPM_PREFIX, and /etc/profile sources it —
# not a per-user, single-shell ~/.profile line that drifts from the prefix.
# Put the npm-global bin on PATH for every login shell. Install the canonical
# snippet from colibri (same file the ISO image uses) with NPM_PREFIX baked in.
install -d -m 0755 "${JAIL_ROOT}/etc/profile.d"
cat > "${JAIL_ROOT}/etc/profile.d/clawdie-npm.sh" <<EOF
# Managed by agent-jail-bootstrap.sh — clawdie npm-global bin on PATH.
PATH="${NPM_PREFIX}/bin:\$PATH"
export PATH
EOF
{
printf 'NPM_PREFIX="%s"\n' "${NPM_PREFIX}"
cat "$(dirname "$0")/clawdie-npm-profile.sh"
} > "${JAIL_ROOT}/etc/profile.d/clawdie-npm.sh"
chmod 0644 "${JAIL_ROOT}/etc/profile.d/clawdie-npm.sh"
if ! grep -q '/etc/profile.d/clawdie-npm.sh' "${JAIL_ROOT}/etc/profile" 2>/dev/null; then

View file

@ -0,0 +1,18 @@
# Clawdie npm-global bin on PATH — single source for ISO image and agent jails.
# Installed by: colibri agent-jail-bootstrap.sh and clawdie-iso build.sh.
# NPM_PREFIX is set by the installer before sourcing this file.
if [ -z "${NPM_PREFIX:-}" ]; then
echo "clawdie-npm-profile: NPM_PREFIX not set — npm-global not added to PATH" >&2
return 0 2>/dev/null || true
fi
case ":${PATH:-}:" in
*:"${NPM_PREFIX}/bin":*) ;;
*) PATH="${NPM_PREFIX}/bin:${PATH}"; export PATH ;;
esac
export npm_config_prefix="${NPM_PREFIX}"
export NPM_CONFIG_PREFIX="${NPM_PREFIX}"
export NPM_CONFIG_UPDATE_NOTIFIER=false
export NO_UPDATE_NOTIFIER=1