Skip to content

Please add the requested version to tool selection output #2033

Open
@hfi-wiit

Description

@hfi-wiit

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions