Skip to content

Please add the requested version to tool selection output #2033

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

Open
hfi-wiit opened this issue Mar 21, 2025 · 1 comment
Open

Please add the requested version to tool selection output #2033

hfi-wiit opened this issue Mar 21, 2025 · 1 comment

Comments

@hfi-wiit
Copy link

hfi-wiit commented Mar 21, 2025

Is your feature request related to a problem? Please describe

If a version file (e.g. .terraform-version, using list-legacy-filenames) requests a version, that is not installed, asdf outputs a list of all versions that are installed:

terraform -version
# No version is set for command terraform
# Consider adding one of the following versions in your config file at /home/hfi/git/# gitlab.boreus.de/kubernetes/terraform/bcp_clusters_vmware/bcp-prod/bcp-boreus-test-salt/.tool-versions
# terraform 1.7.5
# terraform 1.2.7
# terraform 1.11.2
# terraform 1.10.5

It would be nice if that output would also contain the version that was actually requested:

cat .terraform-version 
1.10.4

The functionality itself works just fine, if in the .terraform-version is 1.10.5, output is:

terraform -version
# Terraform v1.10.5
# on linux_amd64
# 
# Your version of Terraform is out of date! The latest version
# is 1.11.2. You can update by downloading from https://www.terraform.io/downloads.html

If there is no tool file:

terraform -version
# Terraform v1.11.2
# on linux_amd64

Describe the proposed solution

So maybe you could just add an additional line like:

No version is set for command terraform
Requested version was: 1.10.4
Consider adding one of the following versions in your config file at /home/hfi/git/gitlab.boreus.de/kubernetes/terraform/bcp_clusters_vmware/bcp-prod/bcp-boreus-test-salt/.tool-versions
terraform 1.7.5
terraform 1.2.7
terraform 1.11.2
terraform 1.10.5

If that version is simply named it is easy to just install it.
Otherwise you have to look what version you need and where it is defined.
Also you could get the output wrong in the first place, since nothing in the message tells, that the issue is, that a version was requested, but it isn't there.

And actually it should be very easy to implement, since you should have the requested version at hand either way in the code path at that time.

asdf info

OS:
Linux hfi-ukw 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
GNU bash, Version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder jünger <http://gnu.org/licenses/gpl.html>

Dies ist freie Software.  Sie darf verändert und verteilt werden.
Es wird keine Garantie gewährt, soweit das Gesetz es zulässt.

BASH VERSION:
5.2.21(1)-release

ASDF VERSION:
v0.16.5

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/hfi/.asdf
ASDF_CONFIG_FILE=/home/hfi/.asdfr
@hfi-wiit
Copy link
Author

It was really relatively easy, I added a PR.
Feel free to improve/change as you want.

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

No branches or pull requests

1 participant