asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
https://asdf-vm.com/
MIT License
21.86k stars 777 forks source link

No executable found error for tools listed in .tool-versions #1336

Open asampal opened 2 years ago

asampal commented 2 years ago

Describe the Bug

For some reason, every once in a while asdf will lose knowledge of which tool version to run if there is a .tool-versions file for that tool in a directory. asdf list, when executed in that directory, shows no * beside any of the tools which are referenced in the .tool-versions file. An error like No <tool> executable found for <tool> <version> is emitted in this case. Invoking asdf local <tool> <version> (with the same version referenced in .tool-versions) will make asdf regain the correct tool version state for the directory in question.

image

Steps to Reproduce

It's not clear what causes the described loss of state for a directory containing a .tool-versions file.

Expected Behaviour

When a .tool-versions file exists, and the tool versions referenced therein are installed, asdf should not end up in a state where the version to be used is unknown.

Actual Behaviour

asdf doesn't know which version of a tool it should use.

Environment

Ubuntu under Windows WSL2.

adi@CR1-7H6Q493:/mnt/c/devenv/projects/terraform-helm/terraform/vagrant/dev-pmt$ asdf info
OS:
Linux CR1-7H6Q493 5.15.62.1-microsoft-standard-WSL2 #1 SMP Wed Aug 24 22:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

ASDF VERSION:
v0.10.2-b8f6218

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/adi/.asdf

ASDF INSTALLED PLUGINS:
awscli                       https://github.com/MetricMike/asdf-awscli.git main c645552
boundary                     https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
calicoctl                    https://github.com/teejaded/asdf-calicoctl.git master c7e35dd
consul                       https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
helm-docs                    https://github.com/sudermanjr/asdf-helm-docs.git master 2fbb98f
helm                         https://github.com/Antiarchitect/asdf-helm.git master a39e17b
k9s                          https://github.com/looztra/asdf-k9s master 2102e69
kubectl                      https://github.com/asdf-community/asdf-kubectl.git master 3d00592
levant                       https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
mc                           https://github.com/penpyt/asdf-mc.git master b0458cf
minikube                     https://github.com/alvarobp/asdf-minikube.git master 8ca7b8d
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master 65441d3
nomad                        https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
packer                       https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
sentinel                     https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
serf                         https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
teleport-ent                 https://github.com/highb/asdf-teleport-ent main fa25f4b
terraform-ls                 https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
terraform                    https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
tfc-agent                    https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
vault                        https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6
waypoint                     https://github.com/asdf-community/asdf-hashicorp.git master bc4dec6


### asdf plugins affected (if relevant)

_No response_
asampal commented 2 years ago

I'm not totally sure, but it seems the issue could be triggered when the directory in which .tool-versions is found is updated as part of a git pull. I don't know if it always happens as a result, but that action is one possible trigger for the state loss.

kelcecil commented 2 years ago

I have several students having this same issue under WSL2 when working on Elixir/Phoenix assignments. Thanks for the confirmation of the issue and the workaround. I'll see if I can dig in, reproduce, and see what I can figure out.

jthegedus commented 1 year ago

asdf resolves the .tool-versions on command execution, so the change of state with git shouldn't affect this. When you exec terraform after doing a git pull, asdf should then lookup the version as the shim executes.

When this happens to someone next, can you please share the following:

asdf current will be the interesting one to see here.

asampal commented 1 year ago

I haven't seen this happening recently. I think the problem stopped after I added .tool-versions to .gitignore.

jthegedus commented 1 year ago

I haven't seen this happening recently. I think the problem stopped after I added .tool-versions to .gitignore.

Well, that's certainly not how we recommend things to work. The whole intent is to capture your .tool-versions in git to share.

asampal commented 1 year ago

Of course, just that in my case I'm the only one using asdf so this wasn't an issue. Also, I'm not totally sure that the ignore was what made things work, since I didn't really look further.

asampal commented 1 year ago

Another bit of context which might help is that the git pull operation was done using Windows git (I have a preferred GUI client). Could it be that during these pulls, there were some line ending changes causing the problem?

jthegedus commented 1 year ago

That could be a potential cause. It is a hard scenario for us to test.

l-z commented 1 year ago

This happened on my mac as well.

"asdf local " again to update the local ".tool-versions" fix the issue.