asdf-vm / asdf-vm/asdf

Please add the requested version to tool selection output

Open
#2,033 2 comments 5 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### 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:

```sh
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:

```sh
cat .terraform-version
1.10.4
```

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

```sh
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:

```sh
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

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
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the asdf CLI path that prints “No version is set for command terraform” when a version from .terraform-version or .tool-versions is unavailable, using the requested and installed versions shown in the issue. Done means the missing requested version is identified in that output while the existing installed-version list and successful selection behavior remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.