asdf
asdf copied to clipboard
Identify different class of error between *missing version* from *requiring a reshim*
Describe the bug
We get a number of bug reports around the error No preset version installed for command <CMD>
message. Some of the time the set version for the tool is not installed and this error message is correct. Other times it is not correct because the version is installed as required, but the plugin requires a reshim as a binary was installed using the tool and asdf
needs to create a shim for the new binary.
We see this with any tool that can install binaries through it's own package manager (Ruby, Golang, Node.js etc)
The most recent example is https://github.com/asdf-vm/asdf/issues/914 is an example of this:
No preset version installed for command <golang binary>
Please install a version by running one of the following:
asdf install golang 1.16.2
or add one of the following versions in your config file at HOME/.tool-versions
golang 1.15.1
where the <golang binary>
was installed and used before reshimming the plugin (asdf reshim golang
).
To Reproduce
See #914
Expected behavior
As mentioned by OP in https://github.com/asdf-vm/asdf/issues/914#issuecomment-827180264 the error message should notify the user to reshim when the specified version of the tool is installed.
Auto reshimming (#409 / #446) would resolve this class of errors. Notably, plugins can run the reshim themselves. The Node.js plugin uses the npm postinstall hook to run the reshim after installation (the Node package manager used must support the npm hooks though so this may be a brittle soln.)
Actual behavior
We get an indication to install the tool instead of reshim.
Environment
Copied from #914
OS:
Darwin Kalorme 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
SHELL:
zsh 5.8 (x86_64-apple-darwin20.0)
ASDF VERSION:
v0.8.0
ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/usr/local/opt/asdf
ASDF INSTALLED PLUGINS:
golang https://github.com/kennyp/asdf-golang.git
minio https://github.com/aeons/asdf-minio.git
nodejs https://github.com/asdf-vm/asdf-nodejs.git
postgres https://github.com/smashedtoatoms/asdf-postgres.git
protoc https://github.com/paxosglobal/asdf-protoc.git
python https://github.com/danhper/asdf-python.git
redis https://github.com/smashedtoatoms/asdf-redis.git
ruby https://github.com/asdf-vm/asdf-ruby.git
yarn https://github.com/twuni/asdf-yarn.git
Hey @jthegedus, thanks for opening this, I was just about to!
To contextualise this issue:
I think that from the perspective of a new user, encountering this error is a big stumbling block.
A very common new asdf
user flow is to install a language, install a binary from that language's package manager, and then invoke that binary. This would trigger the error.
Maybe it is someone who wants to start working on a Node.js project with yarn
(quite typical).
$ asdf install nodejs latest:14
$ npm i -g yarn
# Yay! Now let me start building!
$ yarn init
# Oh no! What happened?
No preset version installed for command yarn
Please install a version by running one of the following:
asdf install nodejs 14.16.1
or add one of the following versions in your config file at /home/me/workspace/project/.tool-versions
nodejs 15.14.0
# How do I fix this? Let me try the instructions...
# Oh no, that didn't work.
# What do I do now?
Or, they might want to start working on a Ruby on Rails project (also a typical use). They'd follow a similar flow: install the language, install a binary through the language's package manager (in this case, rails
), and then try to use that binary (rails new
).
I would imagine that these examples show that this flow is disproportionately common.
The problem is that the error message is simply wrong in this typical user flow. The instructions it gives will not fix the problem.
However, the fix is actually very simple: just running asdf reshim
.
Proposed solution
To me, because
- I think this error comes from such a typical usage of
asdf
- where the user has done nothing wrong
- for these users, the error message is incorrect, which is discouraging and introduces substantial unnecessary friction
I think we should change the error message to instruct the user to try running asdf reshim
.
I'm sure this will reduce the contributors' burden of responding to new issues that should have been solved just by reshimming.
I'd love to hear your thoughts because I think this is an opportunity for a substantially better first user experience. I'm happy to submit a PR if you agree.
https://github.com/asdf-vm/asdf/issues/822 May also be solved by this.
@xtyrrell I would like the soln to only show one error and for the correct case. Adding "also try asdf reshim
" would be easier but not the ideal soln. How the code identifies that was suggested by the OP in https://github.com/asdf-vm/asdf/issues/914#issuecomment-827180264
You're welcome to have a go at solving this, it would greatly help!
Hi, thank you for your work on asdf
. I was repeatedly getting the error Not installed. Run "asdf install deno latest"
and I finally managed to figure out what was wrong. It was a user error on my part, and I suspect others may be doing the same.
The problem is that it's possible to set the version of a plugin to latest
in .tool-versions
and asdf
won't complain:
$ cat .tool-versions
nodejs lts-fermium
firebase latest
$ asdf install
firebase 9.17.0 is already installed
nodejs lts-fermium is already installed
$ asdf reshim
$ asdf current
firebase latest Not installed. Run "asdf install firebase latest"
nodejs lts-fermium /Users/me/Projects/rember-v2/.tool-versions
Because it is possible to both asdf install <plugin> latest
and asdf global <plugin> latest
, it is not self-evident that setting latest
in .tool-versions
is not supported (#1012). I think it would be useful to return an error upon running certain commands like asdf install
or asdf current
to notify the user that an explicit version needs to be set.
This is a super confusing problem.
terraform-module-versions --help
No preset version installed for command terraform-module-versions
Please install a version by running one of the following:
asdf install golang 1.16.6
or add one of the following versions in your config file at /Users/ME/projects/SOMEPROJECT/.tool-versions
golang 1.18
I have my global go version set to 1.18, and installed:
go install github.com/keilerkonzept/terraform-module-versions@latest
once I changed to a sub directory (that has a .tool-versions file with golang 1.16.6 set, I try to run that globally installed binary, I get that error. Here’s where the binary lives.
which terraform-module-versions
/Users/ME/.asdf/shims/terraform-module-versions
Is this problem also because ~/.asdf/shims
is actually a "global" and I might have several terminal windows open, and each essentially fighting with each other, and requiring constant reshimming?
In case it helps, I've been experiencing an edge-case with this:
$ asdf version
v0.10.0
$ yarn
No preset version installed for command yarn
Please install a version by running one of the following:
asdf install nodejs 16.16.0
or add one of the following versions in your config file at /Users/me/my-code/.tool-versions
nodejs 16.14.0
$ asdf current
nodejs 16.16.0 /Users/me/my-code/.tool-versions
$ asdf reshim
$ asdf shim-versions node
nodejs 15.6.0
nodejs 12.19.0
nodejs 16.14.0
nodejs 16.16.0
$ asdf shim-versions yarn
nodejs 16.14.0
$ /Users/me/.asdf/installs/nodejs/16.16.0/lib/node_modules/corepack/shims/yarn
yarn install v1.22.15
...
$ yarn
No preset version installed for command yarn
Please install a version by running one of the following:
asdf install nodejs 16.16.0
or add one of the following versions in your config file at /Users/me/my-code/.tool-versions
nodejs 16.14.0
However, the fix is actually very simple: just running
asdf reshim
.
Neither asdf reshim
nor asdf reshim node
resolve the issue for me.
In case it helps, I've been experiencing an edge-case with this:
$ asdf version v0.10.0 $ yarn No preset version installed for command yarn Please install a version by running one of the following: asdf install nodejs 16.16.0 or add one of the following versions in your config file at /Users/me/my-code/.tool-versions nodejs 16.14.0 $ asdf current nodejs 16.16.0 /Users/me/my-code/.tool-versions $ asdf reshim $ asdf shim-versions node nodejs 15.6.0 nodejs 12.19.0 nodejs 16.14.0 nodejs 16.16.0 $ asdf shim-versions yarn nodejs 16.14.0 $ /Users/me/.asdf/installs/nodejs/16.16.0/lib/node_modules/corepack/shims/yarn yarn install v1.22.15 ... $ yarn No preset version installed for command yarn Please install a version by running one of the following: asdf install nodejs 16.16.0 or add one of the following versions in your config file at /Users/me/my-code/.tool-versions nodejs 16.14.0
However, the fix is actually very simple: just running
asdf reshim
.Neither
asdf reshim
norasdf reshim node
resolve the issue for me.
Found this Github issue when encountering the same exact problem. In my case, the node versions are different (14.15.4 and 14.17.0), but the same problem where the shim-versions for node have all the installed versions, while the shim-versions for yarn only have the one.
FWIW, I resolved this by re-running npm i -g yarn
after shimming to the new node version.
FWIW, I resolved this by re-running
npm i -g yarn
after shimming to the new node version.
This has also worked for me.
Found this Github issue when encountering the same exact problem. In my case, the node versions are different (14.15.4 and 14.17.0), but the same problem where the shim-versions for node have all the installed versions, while the shim-versions for yarn only have the one.
This is expected behaviour because each version of a tool (plus its binaries) is installed seperately. If you install yarn
with Nodejs 14.15.4, it will only be accessible while using that version. If you switch to Nodejs 14.17.0, yarn
will not be found, because you haven't installed it for version 14.17.0
Oh, this. This, very much this. I'm thankful for asdf
since I use it to keep multiple versions of node and npm in my work. But just FYI, nearly every time I hit the install ABC version XYZ to check it's already installed, I'm suffering and losing an hour or more (today it's three) before I realize what this message should really be.
I strongly propose to have a doc section, FAQ entry or some such, dedicated to this error and adding a link in the error message, since this error comes in multiple situations, some disambiguation is needed. I humbly add my voice to this request here (from #1631).