asdf-vm / asdf-vm/asdf

bug: Misleading error messages when tool version is not present

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

Description

### Describe the Bug

When attempting to use ASDF tool shims when the version of the tool specified is not installed, ASDF gives an error message suggesting that it did not process the version file at all rather than telling the user that the version specified is not installed.

### Steps to Reproduce

```
workspace % mkdir version_file_test
workspace % cd version_file_test
version_file_test % asdf set python 3.13.2
version_file_test % cat .tool-versions
python 3.13.2
version_file_test % python --version
No version is set for command python
Consider adding one of the following versions in your config file at /Users/MGP1/workspace/version_file_test/.tool-versions
python 3.13.3
python 2.7.18
version_file_test % echo '3.3.1' > .ruby-version
version_file_test % ruby --version
No version is set for command ruby
Consider adding one of the following versions in your config file at /Users/MGP1/workspace/version_file_test/.tool-versions
ruby 3.4.4
ruby 3.3.8
version_file_test % asdf current
Name Version Source Installed
nodejs 24.0.2 /Users/MGP1/.tool-versions true
python 3.13.2 /Users/MGP1/workspace/version_file_test/.tool-versions false - Run `asdf install python 3.13.2`
ruby 3.3.1 /Users/MGP1/workspace/version_file_test/.ruby-version false - Run `asdf install ruby 3.3.1`
```

### Expected Behaviour

Commands that make use of the ASDF shims which are not able to find the version specified should tell the user that the version specified was not found, just like `asdf current` does.

### Actual Behaviour

Commands that make use of the ASDF shims tell the user that no version is set and recommend creating a `.tool-versions` file, as if it did not notice the existing version file at all - this also applies to legacy version files. This is confusing because it implies that something is wrong with ASDF, the ASDF configuration, or the language plugin, rather than the correct cause of the specified version not being currently installed.

### Environment

```shell
~ % asdf info
OS:
Darwin LMAC-77NMQCC-AG 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030 arm64

SHELL:
zsh 5.9 (arm64-apple-darwin24.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
0.18.0 (revision unknown)

ASDF INTERNAL VARIABLES:
ASDF_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/MGP1/.asdf
ASDF_CONFIG_FILE=/Users/MGP1/.asdfrc

ASDF INSTALLED PLUGINS:
nodejs https://github.com/asdf-vm/asdf-nodejs.git
fd2c7f94c4c71416047cacf2af6e4fa819b364b7
python https://github.com/danhper/asdf-python.git
a3a01856098d6d2b9642e382f5b38e70275726d1
ruby https://github.com/asdf-vm/asdf-ruby.git
e26f34622ffe68d14baeb3ab0da533281f805891
~ % cat .asdfrc
legacy_version_file = yes
```

### asdf plugins affected (if relevant)

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported `python --version` and `ruby --version` commands with versions listed in `.tool-versions` and `.ruby-version` but not installed, then compare their shim output with `asdf current`. Trace the shim error path and update the relevant tests or entry point so the message identifies the missing version without suggesting that no version file exists.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.