tfutils / tfenv

Terraform version manager
MIT License
4.48k stars 454 forks source link

ugly 'no such file or directory' message when setting terraform version for the first time #315

Closed miqm closed 2 years ago

miqm commented 2 years ago

Hello,

It's a minor bug and does not affect how tfenv works, but still - looks odd.

When you do not have any version installed and you type tfenv install - it downloads you latest terraform. However - it does not set it as default. you need to use tfenv use {version number} or just tfenv use (second defaults to latest).

However, during that commands (tfenv use) I get following message:

root@18f0602938de:/# tfenv install
Installing Terraform v1.1.2
Downloading release tarball from https://releases.hashicorp.com/terraform/1.1.2/terraform_1.1.2_linux_amd64.zip
######################################################################################################################################################################################################################################################### 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.1.2/terraform_1.1.2_SHA256SUMS
No keybase install found, skipping OpenPGP signature verification
Archive:  tfenv_download.vJn35z/terraform_1.1.2_linux_amd64.zip
  inflating: /usr/local/lib/tfenv/versions/1.1.2/terraform
Installation of terraform v1.1.2 successful. To make this your default version, run 'tfenv use 1.1.2'
root@18f0602938de:/# tfenv use
cat: /usr/local/lib/tfenv/version: No such file or directory
Switching default version to v1.1.2
Switching completed

The part cat: /usr/local/lib/tfenv/version: No such file or directory is very odd - I think we should test for existence of that file and not let bash output that message.

Additionally, perhaps if there is no version installed, tfenv install could automatically set that version as default?

rhoboat commented 2 years ago

I can +1 this. To get around this, after installing terraform using tfenv, I echo "$version" > path/to/tfenv/version. In my case, that file doesn't actually exist and it does affect whether terraform can execute.