fix: return an error when uninstalling a non-installed version#617
Open
suman2280 wants to merge 3 commits into
Open
fix: return an error when uninstalling a non-installed version#617suman2280 wants to merge 3 commits into
suman2280 wants to merge 3 commits into
Conversation
Signed-off-by: Suman Sardar <sudarshansardar22@gmail.com>
…ninstall Signed-off-by: Suman Sardar <sudarshansardar22@gmail.com>
- Add blank lines before return/break per nlreturn. - Drop redundant nil check on sliced result of errors.As. Signed-off-by: Suman Sardar <sudarshansardar22@gmail.com>
suman2280
force-pushed
the
fix/uninstall-error
branch
from
July 13, 2026 16:51
27e8193 to
635c3e3
Compare
Contributor
Author
|
@kvendingoldo Can you please review this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
solves #616
tenv <tool> uninstall <version>used to silently report success when the requested version was not installed locally. This change makes it return a clear<Tool> <version> is not installederror and a non-zero exit code, matching the documented expected behaviour.Fixes the bug described for
tf,tofu,tg(andtm) where runningreported
Uninstallation of <Tool> 0.0.0 successful (directory … removed)even though the version does not exist.What this PR fixes
uninstallSpecificVersioninversionmanager/manager.gorelied onos.RemoveAll, which is a no-op on a non-existent path and returnsnil. Callers therefore reported success even when nothing was installed for the requested version.Implementation
versionmanager/manager.goerrVersionNotInstalledexported package-wide.uninstallSpecificVersionstats the target directory first; missing path -> display the user-facing message and return wrappederrVersionNotInstalled; otherwiseos.RemoveAlland only report success when it actually removes something.Uninstallpropagates the error in both branches: exact version and the constraint path (whenSelectVersionsToUninstallyields an empty selection).UninstallMultipleand the multi-version loop inUninstallcollect per-version errors viaerrors.Join.versionmanager/tenvlib/lib.goTenv.Uninstallnow delegates tomanager.Uninstall(requestedVersion)instead ofUninstallMultiple([]string{requestedVersion}), routing the single-version CLI path through the direct, non-interactive branch and ensuring the new error reaches callers.Tests
versionmanager/uninstall_test.go(new):Uninstall_not_installed_exact_version-- original bug.UninstallMultiple_returns_error_for_not_installed.UninstallMultiple_returns_joined_errors_for_multiple_not_installed-- verifieserrors.Joinwrapping.Uninstall_installed_version_succeeds-- happy path regression.Uninstall_same_version_twice_returns_error-- idempotency.Commits
This PR is split into two commits to keep history readable:
fix(uninstall): return an error when the target version is not installed-- manager logic + tests.fix(tenvlib): route single-version Uninstall through VersionManager.Uninstall-- public-API routing.Test plan
go build ./...go vet ./...gofmt -l versionmanager/cleango test ./versionmanager/... ./versionmanager/tenvlib/...-- all new subtests pass; no regressions in existing suites.