Files
unlimitedcoding/claude/uclaude_uninstall.sh
delta-cloud-208e 06057f864b fix(installers): 8 critical bugs from gpt-5.5 + glm-5.1 audit (Item 17)
Sub-agents reviewed all 26 installer scripts. Fixed (TDD):

BLOCKERS (install fails on platform):
1. claude/uclaude_uninstall.sh: replace `sed -i` → portable `sedi()` helper
   (BSD sed on macOS requires `-i ''`, GNU uses `-i`). Same fix style as
   codex/ucodex_install.sh:sedi.
2. claude/uclaude_install.ps1: abort if $apiKey null after fetch attempt
   (was silently completing install with broken auth env vars). Guard
   added to all 8 ps1 scripts.
3. qwen/uqwen_install.ps1 + uqwen_update.ps1: build trustedFolders.json
   via [ordered]@{} | ConvertTo-Json (PowerShell single-quoted literal
   was preserving `\"` as backslash+quote, producing INVALID JSON).
4. codex/ucodex_update.ps1: check $LASTEXITCODE after Python patcher call
   (native command non-zero exit doesn't throw under
   ErrorActionPreference='Continue' — patcher failure was silent, no
   PowerShell fallback triggered).

HIGH (wrong behavior / regressions):
5. gemini/ugemini_install.ps1 + update.ps1: read $env:UGEMINI_API_KEY
   FIRST (was only checking $env:UCLAUDE_API_KEY — claude variable).
6. gemini/ugemini_update.ps1: download gemini_config.json from PRIVATE
   unlimitedcoding-config (was downloading from public — would 404 after
   Item 14 sanitization).
7. claude/uclaude_update.ps1: drop ANTHROPIC_API_KEY assignment + dynamic
   models fetch (regression — install.ps1 was fixed earlier but update.ps1
   still set both env vars, re-introducing Auth conflict warning).
8. codex/ucodex_install.sh + update.sh: GitHub API curl needs
   `-H "User-Agent: UnlimitedCoding-Installer"` and `-f` flag (default
   curl/X.Y UA gets 403 from GitHub API + silent fail on 5xx).

Bonus fixes pulled in:
- codex/ucodex_install.ps1: switch codex_config download URL to private
  repo (consistency with update.ps1 + Item 14 sanitization)
- codex/ucodex_install.ps1: add `--all` flag to patcher invocation
  (matched between install + update)

Tests: tests/test_installer_bugs_audit.py — 9 GREEN regression guards.
Total: 186 tests GREEN.

Audit transcripts: gpt-5.5 found 24 issues (claude+gemini), glm-5.1
found 11 issues (codex+qwen). Lower-priority items (heredoc unsafe
quoting, lock files, schema validation) deferred to next iteration.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 17:16:43 +00:00

104 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Claude Code — Uninstaller
# Removes Claude Code CLI, settings, env vars, and npm registry config.
#
# Usage: sudo bash uclaude_uninstall.sh
set -euo pipefail
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
# Cross-platform sed -i (macOS BSD sed requires `-i ''`, GNU sed uses `-i`).
# Use `sedi` instead of `sed -i` everywhere in this script.
sedi() {
if [[ "$(uname -s)" == "Darwin" ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Claude Code — Uninstaller |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Uninstall npm package ----
if npm list -g @anthropic-ai/claude-code &>/dev/null 2>&1; then
info "Removing @anthropic-ai/claude-code..."
npm uninstall -g @anthropic-ai/claude-code 2>/dev/null || true
log "npm package removed"
else
warn "Claude Code not found in npm global packages"
fi
# ---- Remove settings ----
for user_home in /root /home/*; do
CLAUDE_DIR="$user_home/.claude"
if [ -d "$CLAUDE_DIR" ]; then
info "Removing $CLAUDE_DIR..."
rm -rf "$CLAUDE_DIR"
log "Removed $CLAUDE_DIR"
fi
CLAUDE_JSON="$user_home/.claude.json"
if [ -f "$CLAUDE_JSON" ]; then
rm -f "$CLAUDE_JSON"
log "Removed $CLAUDE_JSON"
fi
done
# ---- Remove env vars from shell rc files ----
for user_home in /root /home/*; do
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
if [ -f "$rc_file" ] && grep -q 'ANTHROPIC_API_KEY\|CLAUDE_CODE\|Claude Code\|ANTHROPIC_BASE_URL' "$rc_file" 2>/dev/null; then
info "Cleaning env vars from $rc_file..."
sedi '/# Claude Code/d' "$rc_file"
sedi '/# UnlimitedCoding.*[Cc]laude/d' "$rc_file"
sedi '/ANTHROPIC_API_KEY/d' "$rc_file"
sedi '/ANTHROPIC_BASE_URL/d' "$rc_file"
sedi '/CLAUDE_CODE/d' "$rc_file"
log "Cleaned $rc_file"
fi
done
done
# ---- Remove /etc/profile.d script ----
for f in /etc/profile.d/claude-code.sh /etc/profile.d/claude_code.sh; do
if [ -f "$f" ]; then
rm -f "$f"
log "Removed $f"
fi
done
# ---- Remove env vars from /etc/environment ----
if [ -f "/etc/environment" ] && grep -q 'ANTHROPIC_API_KEY\|ANTHROPIC_BASE_URL\|CLAUDE_CODE' /etc/environment 2>/dev/null; then
info "Cleaning /etc/environment..."
sedi '/ANTHROPIC_API_KEY/d' /etc/environment
sedi '/ANTHROPIC_BASE_URL/d' /etc/environment
sedi '/CLAUDE_CODE/d' /etc/environment
log "Cleaned /etc/environment"
fi
# ---- Remove npm registry config ----
info "Removing npm registry config..."
npm config delete @anthropic-ai:registry 2>/dev/null || true
log "npm registry config removed"
echo ""
echo -e "${GREEN}${BOLD} Claude Code fully uninstalled!${RESET}"
echo ""