asdf icon indicating copy to clipboard operation
asdf copied to clipboard

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

Open asampal opened this issue 3 years ago • 9 comments

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 avatar Sep 28 '22 17:09 asampal

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.

asampal avatar Oct 07 '22 19:10 asampal

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.

kelcecil avatar Oct 11 '22 14:10 kelcecil

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
  • asdf list
  • pwd
  • cat .tool-versions
  • execute one of the tools which is failing

asdf current will be the interesting one to see here.

jthegedus avatar Jan 02 '23 00:01 jthegedus

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

asampal avatar Jan 02 '23 01:01 asampal

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.

jthegedus avatar Jan 02 '23 02:01 jthegedus

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 avatar Jan 02 '23 02:01 asampal

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?

asampal avatar Jan 02 '23 04:01 asampal

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

jthegedus avatar Jan 02 '23 05:01 jthegedus

This happened on my mac as well.

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

l-z avatar Sep 21 '23 06:09 l-z