Skip to content

Commit a0dfd5b

Browse files
peterulsteenclaude
andcommitted
PLN-228: fix: improve install script error handling and diagnostics
Capture stderr from claude plugin commands instead of discarding it, add a strip_ansi helper to clean ANSI codes from error output, and display meaningful error messages when marketplace registration or plugin install/update fails. Previously errors were silently swallowed, making installation failures hard to diagnose. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bd2c6ff commit a0dfd5b

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

install.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ BLUE='\033[0;34m'
2020
BOLD='\033[1m'
2121
NC='\033[0m'
2222

23-
info() { echo -e "${GREEN}[✓]${NC} $1"; }
24-
warn() { echo -e "${YELLOW}[!]${NC} $1"; }
25-
err() { echo -e "${RED}[✗]${NC} $1"; }
26-
step() { echo -e "${BLUE}[→]${NC} ${BOLD}$1${NC}"; }
23+
info() { echo -e "${GREEN}[✓]${NC} $1"; }
24+
warn() { echo -e "${YELLOW}[!]${NC} $1"; }
25+
err() { echo -e "${RED}[✗]${NC} $1"; }
26+
step() { echo -e "${BLUE}[→]${NC} ${BOLD}$1${NC}"; }
27+
strip_ansi() { echo "$1" | sed 's/\x1b\[[0-9;]*m//g'; }
2728

2829
# ── Constants ────────────────────────────────────────────────────────────────
2930
MARKETPLACE_SOURCE="closedloop-ai/claude-plugins"
@@ -73,11 +74,15 @@ echo
7374
# ── Add marketplace ─────────────────────────────────────────────────────────
7475
step "Registering closedloop-ai marketplace..."
7576

76-
if claude plugin marketplace add "$MARKETPLACE_SOURCE" 2>/dev/null; then
77+
if MARKETPLACE_ERR=$(claude plugin marketplace add "$MARKETPLACE_SOURCE" 2>&1); then
7778
info "Marketplace registered: $MARKETPLACE_SOURCE"
7879
else
79-
# May already be registered — not a fatal error
80-
warn "Marketplace may already be registered (continuing)"
80+
MARKETPLACE_ERR_CLEAN=$(strip_ansi "$MARKETPLACE_ERR")
81+
if echo "$MARKETPLACE_ERR_CLEAN" | grep -qiE 'already|exists'; then
82+
warn "Marketplace already registered: $MARKETPLACE_SOURCE (continuing)"
83+
else
84+
warn "Marketplace registration failed: $MARKETPLACE_ERR_CLEAN"
85+
fi
8186
fi
8287

8388
echo
@@ -90,16 +95,20 @@ FAILED=0
9095

9196
for plugin in "${PLUGINS[@]}"; do
9297
PLUGIN_REF="${plugin}@${MARKETPLACE_NAME}"
93-
if claude plugin install "$PLUGIN_REF" --scope user 2>/dev/null; then
98+
if INSTALL_ERR=$(claude plugin install "$PLUGIN_REF" --scope user 2>&1); then
9499
info "Installed: $plugin"
95100
INSTALLED=$((INSTALLED + 1))
96101
else
97102
# May already be installed — try to update instead
98-
if claude plugin update "$PLUGIN_REF" --scope user 2>/dev/null; then
103+
if UPDATE_ERR=$(claude plugin update "$PLUGIN_REF" --scope user 2>&1); then
99104
info "Updated: $plugin"
100105
INSTALLED=$((INSTALLED + 1))
101106
else
102107
warn "Could not install/update: $plugin"
108+
INSTALL_ERR_CLEAN=$(strip_ansi "$INSTALL_ERR")
109+
UPDATE_ERR_CLEAN=$(strip_ansi "$UPDATE_ERR")
110+
[[ -n "$INSTALL_ERR_CLEAN" ]] && warn "install: $INSTALL_ERR_CLEAN"
111+
[[ -n "$UPDATE_ERR_CLEAN" ]] && warn "update: $UPDATE_ERR_CLEAN"
103112
FAILED=$((FAILED + 1))
104113
fi
105114
fi

0 commit comments

Comments
 (0)