Skip to content

bug: Misleading error messages when tool version is not present #2142

Open
@masongup-mdsol

Description

@masongup-mdsol

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

~ % 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions