forked from bchanot/claude
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:
+10
-2
@@ -27,7 +27,15 @@ echo "── Updating Claude Code CLI..."
|
||||
if command -v claude &>/dev/null; then
|
||||
CURRENT_VER=$(claude --version 2>/dev/null | head -1 || echo "unknown")
|
||||
info "Current: $CURRENT_VER"
|
||||
if npm install -g @anthropic-ai/claude-code@latest 2>/dev/null; then
|
||||
# Use the updater that matches the install channel: npm-managed installs
|
||||
# update via npm; native-installer installs self-update via `claude update`
|
||||
# (npm would EEXIST on the ~/.local/bin/claude symlink it does not own).
|
||||
if npm ls -g @anthropic-ai/claude-code &>/dev/null; then
|
||||
UPDATE_CMD=(npm install -g @anthropic-ai/claude-code@latest)
|
||||
else
|
||||
UPDATE_CMD=(claude update)
|
||||
fi
|
||||
if "${UPDATE_CMD[@]}" &>/dev/null; then
|
||||
NEW_VER=$(claude --version 2>/dev/null | head -1 || echo "unknown")
|
||||
if [ "$CURRENT_VER" = "$NEW_VER" ]; then
|
||||
ok "Claude Code already up to date ($NEW_VER)"
|
||||
@@ -35,7 +43,7 @@ if command -v claude &>/dev/null; then
|
||||
ok "Claude Code updated: $CURRENT_VER → $NEW_VER"
|
||||
fi
|
||||
else
|
||||
warn "Claude Code update failed — try manually: npm install -g @anthropic-ai/claude-code@latest"
|
||||
warn "Claude Code update failed — try manually: ${UPDATE_CMD[*]}"
|
||||
fi
|
||||
else
|
||||
warn "Claude Code not found — install first with: make install"
|
||||
|
||||
Reference in New Issue
Block a user