DEV Community

Mr F.
Mr F.

Posted on

Manage your runtime environments using ASDF and not NVM or RVM etc...

Many of us have used rvm or rbenv to manage Ruby, nvm or n to manage our Node installs, pyenv for Python. The problem is when you need to add other things into the mix like gvm for Go, the list goes on.


ASDF to the rescue!

Manage multiple runtime versions with a single CLI tool

ASDF allows you to manage many environments on a per project basis. ASDF has done for my project management what homebrew did for my Mac.

Let's say for example you had RVM and NVM installed and Dart was done via shell scripts. Sure, you're already on top of it - but why accept the pain involved with managing them on top of the environments themselves?

You may not suffer from any of the above and just have one environment to handle, but nonetheless, make it easy for someone who has to manage or maintain your work after you're done with it.

If you're working on or maintaining multiple projects with a team of people, asdf will make all of your lives much easier.

I'll demonstrate how easy it is to take control and get some of your sanity back.
We'll work with Node for this example.

Install asdf

via Homebrew

brew install asdf

If you are on Linux or are using Linux subsystem on Windows or don't use homebrew on macOS, you can install via git.

Update your shell to handle asdf

These are for anyone who installed via homebrew. If you installed via git, follow the instructions on the asdf website.


echo -e '\n. $HOME/.asdf/' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc


echo -e "\n. $(brew --prefix asdf)/" >> ~/.bash_profile
echo -e "\n. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash" >> ~/.bash_profile

Install plugin dependencies for homebrew

You might not have all the dependencies installed, so you need to run:

brew install \
  coreutils automake autoconf openssl \
  libyaml readline libxslt libtool unixodbc \
  unzip curl

Install a language plugin

ASDF comes with extensive language support via it's plugin system

asdf plugin-add nodejs

For nodejs we will also have to add the release team's OpenPGP keys to main keyring:

bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring

List all versions for this package

asdf list-all nodejs

This will output all the versions you can install via asdf.

Install the version you need

 asdf install nodejs 13.3.0

Let's set a system wide version, which will be the default version.

asdf global nodejs 13.3.0

To install a different version:

 asdf install nodejs 7.9.0

Now set it in your current project or directory by:

asdf local nodejs 7.9.0

How to store your settings

You can store your settings for the project by creating a .tool-versions file.

inside your current project add the following setting:

nodejs 7.9.0

If you commit this to your project and someone else picks it up, asdf will understand what version to use and prompt you to install it if necessary.

Keep asdf up to date

Now you have one manager to manage your multiple development environments. You only need to keep asdf up to date, which is easy peasy.

via homebrew:

brew upgrade asdf

or via git

asdf update

Rinse and repeat!

You can rinse and repeat this for as many environments as you need, in as many projects as necessary.

How easy is that!


Discussion (4)

truongnguyen012 profile image

I got this error when install nodejs by asdf install nodejs 14.10.0:
Authenticity of checksum file can not be assured! Please be sure to check the README of asdf-nodejs in case you did not yet import the needed PGP keys. If you already did that then that is the point to become SUSPICIOUS! There must be a reason why this is failing. If you are installing an older NodeJS version you might need to import OpenPGP keys of previous release managers. Exiting.

Please help!

0xdonut profile image
Mr F. Author

did you add the pgp keys to your bash/zsh file?
if you did you will need to re-source the file or open a new terminal and it should resolve your problem

blemoine167 profile image

Thank you for the post, i just discovered asdf cause of your post. Some things changed in the install process so the post is more or less obsolete now. Please refer to the official doc :

muescha profile image
Michael • Edited on

is it right that the ZSH example pipes to .bash_profile? should this not be the .zshrc?