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

Issue with TFENV_AUTO_INSTALL and latest:<regex> syntax #216

Closed
mpescetto opened this issue Oct 6, 2020 · 2 comments · Fixed by #272
Closed

Issue with TFENV_AUTO_INSTALL and latest:<regex> syntax #216

mpescetto opened this issue Oct 6, 2020 · 2 comments · Fixed by #272
Assignees
Labels

Comments

@mpescetto
Copy link

When navigating into the directory with a .terraform-version file with this content: latest:^0.13 it doesn't auto install correctly. Instead I get this:

[mpescetto:~/test/test2]$ export TFENV_DEBUG=2
[mpescetto:~/test/test2]$ terraform -version
[DEBUG] Sourcing helpers from /usr/local/Cellar/tfenv/2.0.0/lib/helpers.sh
/usr/local/bin/terraform: DEBUG trap set
/usr/local/bin/terraform: Helpers sourced successfully
/usr/local/bin/terraform: $PATH does not contain '/usr/local/Cellar/tfenv/2.0.0/libexec', prepending and exporting it now
/usr/local/bin/terraform: $PATH does not contain '/usr/local/Cellar/tfenv/2.0.0/bin', prepending and exporting it now
/usr/local/bin/terraform: program="terraform"
/usr/local/bin/terraform: Exec: "/usr/local/Cellar/tfenv/2.0.0/bin/tfenv" exec "-version"
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: TFENV_HELPERS is set, not sourcing helpers again
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/libexec', not adding it again
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/bin', not adding it again
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: Setting TFENV_DIR to /Users/mpescetto/test/test2
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: tfenv argument is: exec
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: Long argument provided: exec
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: Resulting command-path: /usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec
/usr/local/Cellar/tfenv/2.0.0/bin/tfenv: Exec: "/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec" "-version"
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec: TFENV_HELPERS is set, not sourcing helpers again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/libexec', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/bin', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-exec: Getting version from tfenv-version-name
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: TFENV_HELPERS is set, not sourcing helpers again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/libexec', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/bin', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-file: TFENV_HELPERS is set, not sourcing helpers again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-file: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/libexec', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-file: $PATH already contains '/usr/local/Cellar/tfenv/2.0.0/bin', not adding it again
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-file: Looking for a version file in /Users/mpescetto/test/test2
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-file: Found at /Users/mpescetto/test/test2/.terraform-version
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: TFENV_VERSION_FILE retrieved from tfenv-version-file: /Users/mpescetto/test/test2/.terraform-version
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: TFENV_VERSION specified in TFENV_VERSION_FILE: latest:^0.13
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: TFENV_VERSION uses 'latest' keyword: latest:^0.13
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: 'latest' keyword uses regex: ^0.13
/usr/local/Cellar/tfenv/2.0.0/libexec/tfenv-version-name: No installed versions of terraform matched 'latest:^0.13'
Here's a shell for debugging the current environment. 'exit 0' to resume script from here. Non-zero exit code will abort - parent shell will terminate.

Even trying to list with this fails:

[mpescetto:~/test/test2]$ tfenv list
No installed versions of terraform matched 'latest:^0.13'
tfenv-version-name failed

but if I just do the tfenv install it installs correctly:

[mpescetto:~/test/test2]$ tfenv install
Installing Terraform v0.13.4
Downloading release tarball from https://releases.hashicorp.com/terraform/0.13.4/terraform_0.13.4_darwin_amd64.zip
######################################################################## 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/0.13.4/terraform_0.13.4_SHA256SUMS
No keybase install found, skipping OpenPGP signature verification
Archive:  tfenv_download.33M9Ak/terraform_0.13.4_darwin_amd64.zip
  inflating: /usr/local/Cellar/tfenv/2.0.0/versions/0.13.4/terraform
Installation of terraform v0.13.4 successful. To make this your default version, run 'tfenv use 0.13.4'

So not sure why it's failing. I'll do mystery best to take a look at it.

@iamhsa
Copy link
Contributor

iamhsa commented Jan 23, 2021

Something seems to be wrong with the "latest" keyword.
When I try to reproduce your use-case, the result is different (because a 0.13.x is also installed)

❯ tfenv --version
tfenv 2.0.0-37-g0494129
❯ cat .terraform-version
latest:^0.13

Let see installed versions

❯ tfenv list
* 0.13.5 (set by /home/hugosalesses/workspace/private/terraform-examples/.terraform-version)
  0.12.30
  0.11.14

Hum ! 0.13.5 is the latest 0.13 installed version but not the latest 0.13 (0.13.6)
And terraform execution show the same wrong version

❯ terraform version
Terraform v0.13.5

Your version of Terraform is out of date! The latest version
is 0.14.5. You can update by downloading from https://www.terraform.io/downloads.html

I think something need to be fixed with the latest keyword.

@Zordrak Zordrak self-assigned this Feb 6, 2021
@Zordrak Zordrak added the bug label Feb 6, 2021
@JonZeolla
Copy link

I agree

$ TFENV_TERRAFORM_VERSION=latest:^0.12 tfenv exec version
No installed versions of terraform matched 'latest:^0.12'
$ TFENV_TERRAFORM_VERSION=0.12.30 tfenv exec version
version '0.12.30' is not installed (set by TFENV_TERRAFORM_VERSION). Installing now as TFENV_AUTO_INSTALL==true
Installing Terraform v0.12.30
Downloading release tarball from https://releases.hashicorp.com/terraform/0.12.30/terraform_0.12.30_linux_amd64.zip
######################################################################## 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/0.12.30/terraform_0.12.30_SHA256SUMS
No keybase install found, skipping OpenPGP signature verification
Archive:  tfenv_download.nwfk3i/terraform_0.12.30_linux_amd64.zip
  inflating: /root/.tfenv/versions/0.12.30/terraform
Installation of terraform v0.12.30 successful. To make this your default version, run 'tfenv use 0.12.30'
Terraform v0.12.30

Your version of Terraform is out of date! The latest version
is 0.14.9. You can update by downloading from https://www.terraform.io/downloads.html```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants