Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to install new version when using environment variable #441

Open
tjcelaya opened this issue Jan 2, 2025 · 1 comment
Open

unable to install new version when using environment variable #441

tjcelaya opened this issue Jan 2, 2025 · 1 comment

Comments

@tjcelaya
Copy link

tjcelaya commented Jan 2, 2025

As stated in the title I am unable to install a new version of Terraform when the TFENV_TERRAFORM_VERSION environment variable is set. Terminal session pasted below:

$ tfenv
tfenv 3.0.0
Usage: tfenv <command> [<options>]
...
$ tfenv install 1.10.2
Terraform v1.9.5 is already installed
$ tfenv list
* 1.9.5 (set by TFENV_TERRAFORM_VERSION)
  1.6.6
  1.5.7
  1.5.3
$ unset TFENV_TERRAFORM_VERSION
$ tfenv list
  1.9.5
* 1.6.6 (set by /opt/homebrew/Cellar/tfenv/3.0.0/version)
  1.5.7
  1.5.3
$ tfenv install 1.10.2
Installing Terraform v1.10.2
Downloading release tarball from https://releases.hashicorp.com/terraform/1.10.2/terraform_1.10.2_darwin_arm64.zip
########################################################################################################################################## 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.10.2/terraform_1.10.2_SHA256SUMS
Not instructed to use Local PGP (/opt/homebrew/Cellar/tfenv/3.0.0/use-{gpgv,gnupg}) & No keybase install found, skipping OpenPGP signature verification
Archive:  /var/folders/5s/ykr2l85x7ngbd45q1nvtmss40000gn/T/tfenv_download.XXXXXX.mPvCtPOJhA/terraform_1.10.2_darwin_arm64.zip
  inflating: /opt/homebrew/Cellar/tfenv/3.0.0/versions/1.10.2/LICENSE.txt
  inflating: /opt/homebrew/Cellar/tfenv/3.0.0/versions/1.10.2/terraform
Installation of terraform v1.10.2 successful. To make this your default version, run 'tfenv use 1.10.2'
$ tf version
Terraform v1.10.2
on darwin_arm64
$ tfenv list
* 1.10.2 (set by /opt/homebrew/Cellar/tfenv/3.0.0/version)
  1.9.5
  1.6.6
  1.5.7
  1.5.3
@AliDavoodi98
Copy link

AliDavoodi98 commented Jan 5, 2025

@tjcelaya When you set the TFENV_TERRAFORM_VERSION environment variable, tfenv prioritizes it for determining the active Terraform version. This affects how tfenv processes version resolution and installation.

You can track this by setting TFENV_DEBUG=1 before the installation but essentially when you run tfenv install [<version>]:

  1. tfenv-install would try to resolve the requested version with: tfenv-resolve-version 1.10.2.
  2. tfenv-resolve-version checks for TFENV_TERRAFORM_VERSION to see if you have declared such environment variable and if so, it would pin the requested version to that.
  3. tfenv-resolve-version processes the pinned version and determines whether it is already installed. If the version is found to be installed, the installation process ends here.

So, according to the logic of tfenv-resolve-version, it seems to be expected as tfenv-resolve-version gives precedence to the TFENV_TERRAFORM_VERSION variable.

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

No branches or pull requests

2 participants