asdf-vm - Manage multiple runtime versions with a single CLI tool

Tools
Published on July 23, 2023

I'm using asdf-vm for managing multiple runtime versions with a single CLI tool since 2022.

This is a great tool for managing multiple versions of different runtimes like Node.js, Python, Ruby, Java, Elixir, Erlang, etc. It let you define a .tool-versions file in your project root directory and it will automatically switch to that version when you enter the directory. It also allows you to install multiple versions of the same runtime and switch between them on the fly.

Installation

This tool is available for Linux, macOS, and Windows. You can find the installation instructions here. It supports also a lot of shells like bash, fish, zsh, and powershell.

Usage

It's pretty simple to use. You should install plugin that add support of your favourite tool. For example for node.js it looks like this:

1asdf plugin add nodejs

Then you can install any version of node.js you want:

1asdf install nodejs 16.0.0

And then you can set this version as global:

1asdf global nodejs 16.0.0

Or you can set it as local for your project:

1asdf local nodejs 16.0.0

More plugin can be found in asdf-community.

.tool-versions

You can also define .tool-versions file in your project root directory and it will automatically switch to that version when you enter the directory. It's pretty useful when you have multiple projects with different versions of the same runtime.

1nodejs 16.0.0
2python 3.9.5

Or if you don't have such tool installed it will ask you to install it.

Some useful plugins I'm using

  • nodejs - Manage multiple Node.js versions using node-build
  • direnv - Super useful plugin that solves performance issues in asdf and let you manage your environment variables in .envrc file.
  • golang - Manage multiple Go versions, also support detecting go version from go.mod file.
  • golangci-lint - Manage multiple versions of golangci-lint - Go linters runner.
  • pre-commit - Manage multiple versions of pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.
  • k6 - Manage multiple versions of k6 - A modern load testing tool, using Go and JavaScript.
  • python - Manage multiple Python versions using python-build.

Conclusion

I'm using this tool for a long time and I'm pretty happy with it. It's a great tool for managing multiple versions of different runtimes. It's also pretty easy to use and it's well documented. I recommend you to try it out. You can find more information on the official website.