Yejun Su

March 8, 2022

Manage multiple runtime versions with asdf

Today I introduced asdf in our team, published here as a backup.

To manage various runtime versions, almost all languages has their own version managers, for example, here is a short list:

If you are using multiple runtimes for development, you may face the pitfalls to install and maintain different kinds of version managers. Although it is not cumbersome to use any of them, there is an overhead of context switching in your brain. So asdf comes along.

What is asdf?
From the website, asdf’s target is to “Manage multiple runtime versions with a single CLI tool”. It achieves the target through plugins, currently it has 445 plugins, including almost all runtimes. It actually still uses the managers mentioned above, but as a unified command line.

How to use asdf?
See to install on your machine. 
After that, it comes to the real cases, here we uses Ruby and NodeJS as an example:

# List all plugins
asdf plugin list all

# Install plugins for runtimes
asdf plugin add ruby
asdf plugin add nodejs

# List installed plugins
asdf plugin list

# List all verions
asdf list all ruby
asdf list all nodejs

# Install a version
asdf install ruby 2.7.5
asdf install nodejs 16.13.0

# View installed version
asdf list ruby
asdf list nodejs

# Use runtimes in current project
asdf local ruby 2.7.5
asdf local nodejs 16.13.0

# Use runtimes globally
asdf global ruby 2.7.5
asdf global nodejs 16.13.0

# Use runtimes only in current shell
asdf shell ruby 2.7.5
asdf shell nodejs 16.13.0

# Check runtimes that are currently using
asdf current

It absolutely reduces the complexity of managing runtime versions with asdf, I recommend to have a try and you’ll love it.

- Yejun

About Yejun Su

Software engineer @eduvo. I write about software development, work and life.