fix(install): make Claude Code install/update idempotent across channels

install.sh aborted with npm EEXIST when claude was already present:
the binary is a native-installer symlink (~/.local/bin/claude ->
~/.local/share/claude/versions/*) that npm does not own, and the
npm prefix (~/.local, set for BLK-013) targets the same path. The
`else err` branch turned EEXIST into a fatal exit. No presence guard
existed, unlike the RTK/GSD steps.

- install.sh: skip-if-present guard (command -v claude), mirroring
  the RTK/GSD pattern; npm only runs on a truly fresh machine.
- update-all.sh: pick updater by channel — npm for npm-managed
  installs, `claude update` for native installs (npm would EEXIST).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bastien Chanot
2026-07-01 16:07:13 +02:00
co-authored by Claude
parent 2d76233b02
commit 8dc4027c4b
2 changed files with 18 additions and 4 deletions
+8 -2
View File
@@ -54,9 +54,15 @@ ok "npm $(npm -v)"
# ── 2. Install Claude Code CLI ──
echo ""
echo "── Installing Claude Code (latest)..."
echo "── Installing Claude Code..."
if npm install -g @anthropic-ai/claude-code@latest; then
# Idempotent: an existing claude (native installer under ~/.local/share/claude,
# or any prior install) already owns ~/.local/bin/claude — npm cannot clobber a
# symlink it does not manage (EEXIST). Mirror the RTK/GSD skip-if-present guard;
# upgrades are `make update`'s job (update-all.sh), not first-time install.
if command -v claude &>/dev/null; then
ok "Claude Code already installed ($(claude --version 2>/dev/null | head -1))"
elif npm install -g @anthropic-ai/claude-code@latest; then
ok "Claude Code installed: $(claude --version 2>/dev/null || echo 'unknown')"
else
err "Claude Code installation failed"