asdf current shows node, but zsh can't find node command
Asked Answered
A

2

5

I am new to asdf. I installed asdf on via brew and enabled the asdf plugin in oh-my-zsh. Then I installed nodejs by asdf plugin add node and asdf install node, my .asdf current returns this

$ asdf current
nodejs          21.6.1          /Users/gefei/.tool-versions

But when I then do node, I just got an error:

$ node
zsh: command not found: node

What's going wrong?

EDIT: asdf reshim does not help, but asdf exec node works.

PS: I am sorry for the title, but I just could not find a good title which meets the quality standards of SE. For any advice I would be grateful

Antimonous answered 6/2 at 8:29 Comment(6)
Can you expand the post with how exactly you set up asdf? And does running asdf exec node work?Erbe
Also see this FAQ entry: Shell not detecting newly installed shims?Erbe
@Erbe Yes, asdf exec node works, but asdf reshim does not helpAntimonous
And you verified that you added the correct line into your .zshrc? After you make changes to .zshrc you either need to resource the config or open a new shell to have the config applied.Erbe
@Erbe I put some more explanation into the question. Basically I installed asdf by HomeBrew, and enabled the asdf plugin in oh-my-zsh. Currently I have the following plugins: plugins=(git asdf virtualenv node). I did not change my .zshrc manually cause I think the asdf plugin of oh-my-zsh must suffice. Doesn't it?Antimonous
I think that should be right... maybe try moving the asdf plugin after the node plugin?Erbe
A
7

I spent about 40 minutes on this, and finally found a simple solution: I simply added the path /Users/gefei/.asdf/shims/ to my $PATH$ and then it works fine.

I actually don't know whose job it is to put a line to .zshrc to automate this, so I decided to write an answer to this question, hoping someone will find it helpful.

Antimonous answered 6/2 at 11:19 Comment(1)
Thank you, I would have wasted a lot more of my time alsoLachance
D
0

Alternatively, this line on your .zshrc file should solves as well:

. /opt/homebrew/opt/asdf/libexec/asdf.sh

Basically this add necessary content on your $PATH.

Dorolisa answered 21/10 at 3:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.