Skip to content

bug: error for missing shim version is confusing #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gurgeous opened this issue Jan 14, 2022 · 5 comments
Closed

bug: error for missing shim version is confusing #1162

gurgeous opened this issue Jan 14, 2022 · 5 comments
Labels

Comments

@gurgeous
Copy link

Describe the Bug

I am trying to move my team to asdf. One of my coworkers encountered this error, which is somewhat cryptic (and incorrect). Maybe we can improve it?

Thanks for creating such a great project, we love asdf!

Steps to Reproduce

  1. Setup .tool-versions with nodejs
  2. asdf install. Yarn is not yet installed (for that version of nodejs).
  3. yarn -v to get the error

Expected Behaviour

Can we improve the error message? Perhaps something more like:

asdf is using nodejs 14.17.0 in this directory. You tried to run yarn, but yarn is not
installed for this version of nodejs. Here are a couple of ways to fix this issue:

(1) Install yarn for nodejs 14.17.0.
(2) Maybe you installed yarn in a different version of nodejs? Try switching this
directory to another version of nodejs.

Actual Behaviour

No preset version installed for command yarnpkg
Please install a version by running one of the following:

asdf install nodejs 14.17.0

or add one of the following versions in your config file at /Users/nathan/.tool-versions
nodejs 16.13.2

Environment

OS:
Darwin xxx.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101 arm64

SHELL:
zsh 5.8 (x86_64-apple-darwin20.0)

ASDF VERSION:
v0.9.0

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/opt/homebrew/Cellar/asdf/0.9.0/libexec

ASDF INSTALLED PLUGINS:
nodejs                       [email protected]:asdf-vm/asdf-nodejs.git master ed34355

asdf plugins affected (if relevant)

No response

@gurgeous gurgeous added the bug label Jan 14, 2022
@richardsondx
Copy link

+1

@keshav-c
Copy link

keshav-c commented Dec 31, 2022

This error is still occurring. Any help or update is appreciated 🙏

  1. Running: npm install -g yarn returns npm ERR! File exists: ~/.asdf/installs/nodejs/18.12.1/bin/yarn
  2. I can see yarn and yarnpkg on cding to that location
  3. And it is the latest version (v3.3.1)
  4. Looking up the available shims in ~/.asdf/shims shows that the yarn shims are not there.

To solve this I think ~/.asdf/shims should have an entry for yarn.

@keshav-c
Copy link

Update: I ran the following commands which seem to have solved my issue

> asdf exec yarn -v
unknown command: yarn. Perhaps you have to reshim?
> asdf reshim nodejs 18.12.1
> which yarn
~/.asdf/shims/yarn
> cd back to folder with correct .tool-versions
> which yarn
~/.asdf/shims/yarn
> yarn -v
3.3.1

In summary, I installed the latest stable nodejs, and followed the instructions to setup yarn (using corepack), but the yarn executable was missing from the path. The problem was that the yarn executable wasn't shimmed properly when I installed the new version of nodejs.

@jthegedus
Copy link
Contributor

jthegedus commented Jan 2, 2023

https://asdf-vm.com/more/faq.html#newly-installed-executable-not-running

https://asdf-vm.com/manage/core.html#reshim

We generally recommend against installing globally managed tools via asdf managed runtimes or tools. asdf -> nodejs -> yarn means that whenever you change nodejs version, you would need to reinstall yarn or capture the shim of the global in the new nodejs version. In these cases, it is best to manage that global tool in asdf itself. There is an asdf plugin for yarn.

We have documentation covering this scenario.

Your suggested output is certainly much clearer. The problem here is that this error message is not built in one place in the codebase, but rather built-up throughout the codebase from various other calls so it is a harder to implement than a simple text change.

We can look into this though.

@Stratus3D
Copy link
Member

Stratus3D commented Mar 25, 2025

Closing as I think this is a duplicate of #928. @jthegedus please re-open if I'm wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants