Manage multiple runtime versions with asdf

Manage multiple runtime versions with asdf
Photo by Agence Olloweb / Unsplash

In short: asdf is a tool version manager.

Let's get started with asdf on Linux using bash shell

sudo apt install curl git
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1

Add the following to ~/.bashrc

. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"

For more installation methods check the official docs.

Work with plugins

List all plugins

asdf plugin list all

List added plugins

asdf plugin list --urls

Add a plugin

asdf plugin add NAME REPO_URL

Show latest stable version of a plugin

asdf latest NAME

Show all versions of a plugin

asdf list all NAME

Install tool

asdf install NAME <latest|version>

Show installed tools

asdf list

Show installed versions of a plugin

asdf list NAME

Update plugins

asdf plugin update NAME
asdf plugin update --all

Example: Working with nodejs plugin

# list all plugins
asdf plugin list all

# find nodejs plugin and install it 
asdf plugin list all | grep nodejs

nodejs                       https://github.com/asdf-vm/asdf-nodejs.git

# add plugin
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git

# show latest stable version
asdf latest nodejs

# install nodejs latest version
asdf install nodejs latest

# list all available versions
asdf list all nodejs

# install another version
asdf install nodejs 18.18.2

# show installed versions
asdf list nodejs

  18.18.2
 *21.1.0

Manage plugin versions

asdf keeps tool versions in file named .tool-verions

  • Global file: $HOME/.tool-verions
  • Local file: $PWD/.tool-verions
💡
asdf performs a version lookup of a tool in all .tool-versions files from the current working directory up to the $HOME directory

Set version of a tool in global file

asdf global nodejs latest

Set version of a tool in local file

asdf local nodejs latest

Show current version of tools

asdf current

The output should look like this

awscli          1.29.73         /home/debian/.tool-versions
golang          1.21.3          /home/debian/.tool-versions
helm            3.13.1          /home/debian/.tool-versions
k9s             0.27.4          /home/debian/.tool-versions
kubectl         1.25.15         /home/debian/.tool-versions
nodejs          21.1.0          /home/debian/.tool-versions
velero          1.12.1          /home/debian/.tool-versions

Happy asdf ⭐️!