Skip to content

fix(scripts): remove all detected installations on uninstall#106

Merged
CybotTM merged 1 commit into
mainfrom
fix/uninstall-uv-apt-nvm
Jul 16, 2026
Merged

fix(scripts): remove all detected installations on uninstall#106
CybotTM merged 1 commit into
mainfrom
fix/uninstall-uv-apt-nvm

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes three uninstall bugs found in a real make uninstall-poetry / make uninstall-pnpm session (poetry installed via both uv and apt; pnpm as an npm global inside nvm's node):

  1. No uv removal handlerremove_installation fell through to Unsupported removal method: uv and its non-zero return aborted the whole removal loop under set -e, so the apt installation was never attempted. Added a uv tool uninstall handler and guarded the loop (|| true) — leftovers still surface via the post-removal verify.
  2. nvm misclassification — npm packages inside an nvm node dir (pnpm, eslint, …) classified as nvm(vX) and were blanket-skipped. They now classify as npm(vX) and are removed via npm uninstall -g; only node/npm/npx/corepack stay nvm-managed. This matches the previously dormant assertion in tests/test_guide_multi_install.sh (classify nvm path returns npm(...)).
  3. Wrong-path resolution with multiple installs — the apt and manual handlers re-resolved the binary via command -v, which hits whichever installation shadows the others in PATH; dpkg -S then missed and the apt removal silently no-oped. The detected path is now passed down and preferred.

Also drops an unused local config in can_install_via_method — a pre-existing SC2034 that blocked the shellcheck pre-commit hook on any change to capability.sh.

Tests

  • tests/test_uninstall_fixes.py (11 tests, TDD red→green): uv handler invocation, failing-uv resilience, nvm-vs-npm classification for both classify_install_path and detect_install_method, loop resilience, apt/manual path precision with dpkg/sudo/apt-get PATH stubs
  • Full suite: 673 passed, 1 skipped; tests/test_guide_multi_install.sh: 52 passed, 0 failed; shellcheck clean on the three touched scripts; smoke tests pass

make uninstall-poetry with a uv install + an apt install aborted on the
first: remove_installation had no uv handler, its non-zero return killed
the removal loop under set -e, and the apt handler re-resolved the binary
via command -v — which with multiple installations hits whichever shadows
the others in PATH, so dpkg -S missed and the apt removal no-oped.

- add uv handler (uv tool uninstall)
- guard the removal loop so one failed method no longer aborts the rest;
  leftovers still surface via the post-removal verify
- pass the detected path into remove_installation; apt and
  manual/github_release_binary handlers prefer it over command -v
- classify npm packages inside an nvm node dir (pnpm, eslint, ...) as
  npm(vX) instead of nvm(vX) so they are removable via npm uninstall -g;
  only node/npm/npx/corepack stay nvm-managed (matches the dormant
  assertion in tests/test_guide_multi_install.sh)
- drop an unused local in can_install_via_method (pre-existing SC2034
  that blocked the shellcheck hook on this change)

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 16, 2026 21:44
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.45%. Comparing base (cba0838) to head (814daf9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #106   +/-   ##
=======================================
  Coverage   72.45%   72.45%           
=======================================
  Files          22       22           
  Lines        3402     3402           
=======================================
  Hits         2465     2465           
  Misses        937      937           
Flag Coverage Δ
unittests 72.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CybotTM
CybotTM merged commit cd3c011 into main Jul 16, 2026
21 of 22 checks passed
@CybotTM
CybotTM deleted the fix/uninstall-uv-apt-nvm branch July 16, 2026 21:49
CybotTM added a commit that referenced this pull request Jul 17, 2026
## Summary

Retro follow-ups from this week's bug chain (#106#111):

1. **`scripts/AGENTS.md` — four hard-won invariants**, each of which
caused a shipped bug: never verify installs via PATH lookup (resolve the
manager's bin dir; pass detected paths into removal code), environments
≠ installations (both detection layers must stay in sync), quiet command
wrappers detach stdin and surface failures, and the shellcheck hook
lints the whole changed file.
2. **CI `Shell Tests` job** running `tests/test_guide_multi_install.sh`
(52 assertions) and `tests/test_reconcile_dryrun.sh` (7 assertions) —
they were wired into no job, and a dormant assertion in the former
(`classify nvm path returns npm(...)`) predicted the pnpm/nvm
misclassification fixed in #106 long before it bit.

Both suites verified green locally before wiring.

Came from /retro: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants