asdf-vm

How to get asdf's version to be the version


Explained in terminal, I have installed a version of nodejs using asdf, but the terminal only sees the other version:

> asdf list
nodejs
  12.18.3

> nodejs --version
v8.10.0

> asdf global nodejs 12.18.3 

> nodejs --version          
v8.10.0

Have added the following to the top of .zshrc

. $HOME/.asdf/asdf.sh
export PATH=$HOME/.asdf/asdf.sh:$PATH

Have reloaded .zshrc

> source ~/.zshrc

There are no local files which are setting the local version to 8.10.0.

How do I get nodejs --version to give me the version that asdf acknowledges as the global version?


Solution

  • I had this problem on both Ubuntu 18.04 and Mac 10.15.7. There were several issues.

    Installing asdf with brew (mac) does not install it properly - asdf.sh is missing. The docs suggest installing with git, which works.

    As stated in the docs, the running of asdf.sh (grey box below) needs to be at the BOTTOM of .zshrc (or equivalent profile setting file, such as .bash_profile etc). It adds things to the start of the $PATH.

    . $HOME/.asdf/asdf.sh
    

    Naturally you need to run source .zshrc after modifying it so the terminal reloads the changes. This should result in changing your $PATH, so when you run echo $PATH you should have something that starts with:

    /Users/homersimpson/.asdf/shims:/Users/homersimpson/.asdf/bin:/usr/local/opt/qt@5.5/bin: ...other things separated by ':'
    

    which node should give something like /Users/homersimpson/.asdf/shims/node. It is the shims for asdf being at the start of your path which make asdf's version be the version your system uses.