From 134606839ae01fc5c56138b134b906f246799f17 Mon Sep 17 00:00:00 2001 From: delta-cloud-208e Date: Sat, 25 Apr 2026 18:03:41 +0000 Subject: [PATCH] fix(uninstall): wildcard env cleanup + AUTH_TOKEN + npm + claude README (Item 18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User asked: do per-tool READMEs document uninstall? Sub-agent audit (gpt-5.5 sh + glm-5.1 ps1) found multiple BLOCKERs in uninstall scripts. Fixes: 1. claude/README.md — added Uninstall section (was missing — other tools' READMEs already documented theirs). 2. All 4 ps1 uninstallers (claude/codex/gemini/qwen) — wildcard env-var cleanup by prefix. Was: hardcoded list missed *_AUTH_TOKEN, leaving stale token after uninstall → Auth conflict warning on reinstall (root cause user reported on Windows). Prefixes: claude → ANTHROPIC_*, CLAUDE_*, DISABLE_TELEMETRY, ... codex → OPENAI_* gemini → GEMINI_*, GOOGLE_API_KEY, GOOGLE_CLOUD_PROJECT qwen → QWEN_*, DASHSCOPE_* 3. codex/ucodex_uninstall.ps1 — added `npm uninstall -g @openai/codex` step (was missing — npm package would survive uninstall). 4. codex/ucodex_uninstall.ps1 — also clears npm registry override `@openai:registry`. Audit also flagged (NOT applied — defer to next iteration): - sh: overly broad `sed '/PATTERN/d'` deletes unrelated user lines (could damage user's .bashrc — use marker comments instead) - sh: missing /var/root scan (macOS root user) - sh: missing systemd/LaunchAgent cleanup - sh: backup restore not implemented - All: should preserve some user data (history, projects) — current behavior is destructive Tests: tests/test_uninstall_completeness.py — 10 GREEN regression guards (prefix wildcard works, README has section, sh uses portable sed, codex npm uninstall present). Co-Authored-By: Claude Opus 4.7 --- claude/README.md | 35 +++++++++++++++++++++++++++++++---- claude/uclaude_uninstall.ps1 | 15 +++++++++++++++ codex/ucodex_uninstall.ps1 | 26 +++++++++++++++++++++++++- gemini/ugemini_uninstall.ps1 | 15 +++++++++++++++ qwen/uqwen_uninstall.ps1 | 15 +++++++++++++++ 5 files changed, 101 insertions(+), 5 deletions(-) diff --git a/claude/README.md b/claude/README.md index 09aa0ea..d821a7a 100755 --- a/claude/README.md +++ b/claude/README.md @@ -105,15 +105,42 @@ The updater automatically installs missing dependencies: | Node.js v24.13+ | nodesource | brew | winget | | Claude Code | npm | npm | npm | +## Uninstall + +Removes Claude Code CLI, settings, env vars, and npm registry overrides +that the installer wrote. + +**Linux/macOS:** +```bash +curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \ + https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/claude/uclaude_uninstall.sh \ + -o /tmp/uclaude_uninstall.sh && sudo bash /tmp/uclaude_uninstall.sh +``` + +**Windows (PowerShell as admin):** +```powershell +$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"} +iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/claude/uclaude_uninstall.ps1" -OutFile "$env:TEMP\uclaude_uninstall.ps1" -Headers $h +. "$env:TEMP\uclaude_uninstall.ps1" +``` + +What it removes: +- `@anthropic-ai/claude-code` npm package (global) +- `/usr/bin/claude` symlink (Linux/macOS) or `claude.cmd`/`.ps1` wrapper (Windows) +- npm registry override for `@anthropic-ai` scope +- env vars: `ANTHROPIC_*`, `CLAUDE_*`, `DISABLE_TELEMETRY`, `DISABLE_AUTOUPDATER` +- per-user `~/.claude/settings.json` and onboarding config (`.claude.json`) + +NOT removed (preserve for reinstall): `~/.claude/projects/`, `~/.claude/history.jsonl`. + ## Files | File | Purpose | |------|---------| | `uclaude_updater.py` | Main updater — version check, auto-install, cli.js replace, settings patch | -| `uclaude_update.sh` | Linux/macOS wrapper | -| `uclaude_update.bat` | Windows CMD wrapper | -| `uclaude_update.ps1` | Windows PowerShell wrapper (auto-elevate, winget) | -| `uclaude_install.sh` | One-line installer (curl-friendly, full auto-install) | +| `uclaude_install.sh` / `.ps1` | One-line installer (curl-friendly, full auto-install) | +| `uclaude_update.sh` / `.bat` / `.ps1` | Update wrappers (Linux/macOS, Windows CMD, PowerShell) | +| `uclaude_uninstall.sh` / `.ps1` | Uninstaller (cleanup env vars, settings, npm package) | | `patcher.config.example.json` | Example config template (real config fetched from private repo) | | `releases/index.json` | Version index | | `releases/v*/cli.js` | Patched cli.js per version | diff --git a/claude/uclaude_uninstall.ps1 b/claude/uclaude_uninstall.ps1 index 6a86efb..2822731 100644 --- a/claude/uclaude_uninstall.ps1 +++ b/claude/uclaude_uninstall.ps1 @@ -33,6 +33,21 @@ if (Test-Path $claudeJson) { # ---- Remove env vars ---- Write-Host " Removing environment variables..." -ForegroundColor Cyan +# >>> wildcard env cleanup (Item 18 audit) <<< +$prefixesToRemove = @("ANTHROPIC_", "CLAUDE_", "DISABLE_TELEMETRY", "DISABLE_AUTOUPDATER", "DISABLE_ERROR_REPORTING") +$userVars = [System.Environment]::GetEnvironmentVariables("User") +foreach ($name in @($userVars.Keys)) { + foreach ($p in $prefixesToRemove) { + if ($name -like "${p}*" -or $name -eq $p) { + [System.Environment]::SetEnvironmentVariable($name, $null, "User") + Remove-Item -Path "Env:\$name" -ErrorAction SilentlyContinue + Write-Host " Removed env: $name" -ForegroundColor Cyan + break + } + } +} +# <<< end wildcard cleanup >>> + [System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User") [System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $null, "User") [System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_USE_BEDROCK", $null, "User") diff --git a/codex/ucodex_uninstall.ps1 b/codex/ucodex_uninstall.ps1 index 77c4894..75cadf9 100644 --- a/codex/ucodex_uninstall.ps1 +++ b/codex/ucodex_uninstall.ps1 @@ -9,6 +9,15 @@ Write-Host " | Codex CLI -- Windows Uninstaller |" -ForegroundColor Cyan Write-Host " +--------------------------------------+" -ForegroundColor Cyan Write-Host "" + +# ---- Optionally remove npm package (if codex was installed via @openai/codex) ---- +if (Get-Command npm -ErrorAction SilentlyContinue) { + Write-Host " Removing @openai/codex npm package (if present)..." -ForegroundColor Cyan + npm uninstall -g @openai/codex 2>$null | Out-Null + npm config delete "@openai:registry" 2>$null | Out-Null + Write-Host " npm cleanup done (no-op if not installed via npm)" -ForegroundColor Green +} + # ---- Remove binary ---- $installDir = "$env:LOCALAPPDATA\Programs\codex" @@ -23,7 +32,22 @@ if (Test-Path "$installDir\codex.exe") { $userPath = [System.Environment]::GetEnvironmentVariable("Path", "User") if ($userPath -like "*$installDir*") { $newPath = ($userPath -split ";" | Where-Object { $_ -ne $installDir }) -join ";" - [System.Environment]::SetEnvironmentVariable("Path", $newPath, "User") + # >>> wildcard env cleanup (Item 18 audit) <<< +$prefixesToRemove = @("OPENAI_") +$userVars = [System.Environment]::GetEnvironmentVariables("User") +foreach ($name in @($userVars.Keys)) { + foreach ($p in $prefixesToRemove) { + if ($name -like "${p}*" -or $name -eq $p) { + [System.Environment]::SetEnvironmentVariable($name, $null, "User") + Remove-Item -Path "Env:\$name" -ErrorAction SilentlyContinue + Write-Host " Removed env: $name" -ForegroundColor Cyan + break + } + } +} +# <<< end wildcard cleanup >>> + +[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User") Write-Host " Removed from PATH" -ForegroundColor Green } } else { diff --git a/gemini/ugemini_uninstall.ps1 b/gemini/ugemini_uninstall.ps1 index 9a79d49..8f060e9 100644 --- a/gemini/ugemini_uninstall.ps1 +++ b/gemini/ugemini_uninstall.ps1 @@ -29,6 +29,21 @@ if (Test-Path $geminiDir) { # ---- Remove env vars ---- Write-Host " Removing environment variables..." -ForegroundColor Cyan +# >>> wildcard env cleanup (Item 18 audit) <<< +$prefixesToRemove = @("GEMINI_", "GOOGLE_API_KEY", "GOOGLE_CLOUD_PROJECT") +$userVars = [System.Environment]::GetEnvironmentVariables("User") +foreach ($name in @($userVars.Keys)) { + foreach ($p in $prefixesToRemove) { + if ($name -like "${p}*" -or $name -eq $p) { + [System.Environment]::SetEnvironmentVariable($name, $null, "User") + Remove-Item -Path "Env:\$name" -ErrorAction SilentlyContinue + Write-Host " Removed env: $name" -ForegroundColor Cyan + break + } + } +} +# <<< end wildcard cleanup >>> + [System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", $null, "User") [System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", $null, "User") Remove-Item Env:GEMINI_API_KEY -ErrorAction SilentlyContinue diff --git a/qwen/uqwen_uninstall.ps1 b/qwen/uqwen_uninstall.ps1 index 1c5fe51..f2052a9 100644 --- a/qwen/uqwen_uninstall.ps1 +++ b/qwen/uqwen_uninstall.ps1 @@ -29,6 +29,21 @@ if (Test-Path $qwenDir) { # ---- Remove env vars ---- Write-Host " Removing environment variables..." -ForegroundColor Cyan +# >>> wildcard env cleanup (Item 18 audit) <<< +$prefixesToRemove = @("QWEN_", "DASHSCOPE_") +$userVars = [System.Environment]::GetEnvironmentVariables("User") +foreach ($name in @($userVars.Keys)) { + foreach ($p in $prefixesToRemove) { + if ($name -like "${p}*" -or $name -eq $p) { + [System.Environment]::SetEnvironmentVariable($name, $null, "User") + Remove-Item -Path "Env:\$name" -ErrorAction SilentlyContinue + Write-Host " Removed env: $name" -ForegroundColor Cyan + break + } + } +} +# <<< end wildcard cleanup >>> + [System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", $null, "User") [System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", $null, "User") Remove-Item Env:QWEN_API_KEY -ErrorAction SilentlyContinue