Skip to content

Uninstallation shows successful even when not installed #616

Description

@markmcnaughton

Describe the bug

When uninstalling a package version that is not installed, tenv reports the operation as successful even though the version is not installed and/or does not exist.

e.g.
tenv tf uninstall 0.0.0
Uninstallation of Terraform 0.0.0 successful (directory /home/USERNAME/.tenv/Terraform/0.0.0 removed)

tenv tofu uninstall 0.0.0
Uninstallation of OpenTofu 0.0.0 successful (directory /home/USERNAME/.tenv/OpenTofu/0.0.0 removed)

tenv tg uninstall 0.0.0
Uninstallation of Terragrunt 0.0.0 successful (directory /home/USERNAME/.tenv/Terragrunt/0.0.0 removed)

To Reproduce
Steps to reproduce the behavior:

  1. List the available or installed versions:

tenv tf list-remote

tenv tofu list-remote

tenv tg list-remote

  1. Verify that version 0.0.0 is not installed.

  2. Attempt to uninstall the non-existent version:

tenv tf uninstall 0.0.0

tenv tofu uninstall 0.0.0

tenv tg uninstall 0.0.0

  1. Observe that the command reports a successful uninstallation, for example:

Uninstallation of Terraform 0.0.0 successful (directory /home/USERNAME/.tenv/Terraform/0.0.0 removed)

Expected behavior

If the requested version is not installed, the command should return an error or warning instead of reporting success.

For example:

Terraform 0.0.0 is not installed.

or

Uninstallation of Terraform 0.0.0 failed: version is not installed.

Screenshots
N/A

Environment (please complete the following information):

OS: Arch Linux - 7.0.10-arch1-1
tenv version: v4.14.8

Additional context

The current behavior appears to treat the removal of a non-existent directory as a successful uninstall. It may be worth checking whether the target version exists before reporting success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions