Fix azd tool uninstall for VS Code extensions and GitHub Copilot CLI#8875
Fix azd tool uninstall for VS Code extensions and GitHub Copilot CLI#8875hemarina wants to merge 6 commits into
azd tool uninstall for VS Code extensions and GitHub Copilot CLI#8875Conversation
azd tool uninstall for VS Code extensions (#8830) and GitHub Copilot CLI (#8831)azd tool uninstall for VS Code extensions and GitHub Copilot CLI
…na/fix-tool-uninstall-8830
There was a problem hiding this comment.
Pull request overview
Fixes azd tool uninstall for tools that can’t be reliably removed via a single assumed package manager (notably VS Code extensions with dependency conflicts and the GitHub Copilot CLI’s multi-install-method matrix), improving both behavior and user guidance.
Changes:
- Allows multiple install strategies per platform (ordered preferences), with uninstall using detect-then-remove to choose the manager that actually owns the install.
- Adds Homebrew cask support (
--cask) and Homebrew probing on Linux; improves version detection for brew casks. - Improves uninstall error classification (VS Code dependency conflict vs. winget “lost record” vs. generic package-manager failures) and expands unit test coverage accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/tool/version_provider.go | Updates latest-version lookup to work with multi-strategy manifests and adds brew cask JSON parsing. |
| cli/azd/pkg/tool/version_provider_test.go | Updates tests for multi-strategy manifests and adds brew cask coverage. |
| cli/azd/pkg/tool/platform.go | Adds strategy-list selection and updates strategy selection semantics for ordered strategies. |
| cli/azd/pkg/tool/platform_test.go | Updates tests for multi-strategy selection and adds Linux brew presence assertion. |
| cli/azd/pkg/tool/manifest.go | Extends manifest schema with ordered per-platform strategies and a Homebrew cask flag. |
| cli/azd/pkg/tool/manifest_test.go | Updates manifest invariants for multi-strategy and adds a Copilot CLI install-strategy guard test. |
| cli/azd/pkg/tool/installer.go | Implements detect-then-remove uninstall, cask-aware brew commands, and improved uninstall error classification + guidance. |
| cli/azd/pkg/tool/installer_test.go | Adds comprehensive uninstall tests for multi-method tools, winget lost-record detection, and VS Code dependency conflicts. |
| cli/azd/cmd/tool.go | Updates tool detail display to show multiple install strategies per platform. |
jongio
left a comment
There was a problem hiding this comment.
The detect-then-remove approach is the right pattern here. Scoping packageManagerLostRecord to winget only is correct since brew/npm manifest tracking isn't affected by self-updates.
One observation inline on the version provider strategy selection.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Summary
Fixes two related failures in
azd tool uninstallwhere the command failed (or printed a misleading message) for tools that are not removable through the single package manager azd assumed for each platform.Fixes #8830
Fixes #8831
#8830 —
azd tool uninstall vscode-azure-toolsfails on Windows and macOSCause: VS Code refuses to remove an extension that other installed extensions depend on (e.g. Azure Resources), so
code --uninstall-extension ...exits non-zero with... depend on this.--forcedoes not override this. azd misattributed the failure to the generic "the package no longer has a record / was updated outside the package manager" path.Fix: Detect the VS Code dependency-conflict signature on stderr and surface accurate, actionable guidance (remove the dependent extensions first) instead of the misleading lost-record message.
#8831 —
azd tool uninstall github-copilot-clifails on macOS and LinuxCause: The GitHub Copilot CLI is self-managed and can be installed several ways per platform (npm on all; WinGet on Windows; a Homebrew cask on macOS + Linux; an install script on macOS + Linux), but azd's manifest assumed a single package manager per platform. On Linux, npm wasn't on
PATH→ "package manager npm not available"; on macOS,brew uninstall copilot-clifailed because it is a cask.Fix:
PATHbinary, instead of a misleading package-manager error.brewto the Linux package-manager probe list — thecopilot-clicask publishesx86_64_linux/arm64_linuxbinaries, sobrew install --caskworks on Linux too.--cask) through install, uninstall, and version detection.Testing
cli/azd/pkg/toolupdated and passing;gofmt/go vetclean.azd tool installthenazd tool uninstall, verifying every stage with the actualcopilot --versioncommand:copilot --versionthen fails (gone). ✓copilot --versionthen fails (gone). ✓copilot --versionstill works. ✓