asdf as environment manager

so much faster

Published March 13, 2021 #asdf, #nvm, #rvm, #rbenv

I've switch to using asdf to manage my computers version of different programming environments. This is both a more unified approach to using both nvm and rbenv, since it handles a lot more programming languages, but the implementation is also faster.

Installing asdf

Go to the asdf getting started page to get the latest version:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0

Then add this to your ~/.bashrc:

. $HOME/.asdf/asdf.sh

Add a plugin

Different languages are supported using plugins, so first we need to install a plugin. For example:

asdf plugin add deno

Updating plugins

asdf itself has the code to manage the environment directories and keeping track of the packages. The plugins know all about a specific environment. So if you want to get the latest version of, say, deno, you need to update the plugin because that's where the build instructions live.

asdf plugin update --all

Installing a version

This will list all available versions for a specific environment:

asdf list all deno

We can install the latest with:

asdf install deno latest
∗ Downloading and installing deno...
Archive:  /home/wschenk/.asdf/installs/deno/1.8.1/bin/deno.zip
  inflating: /home/wschenk/.asdf/installs/deno/1.8.1/bin/deno  
The installation was successful!

We can install a specific version with:

asdf install deno 1.6.3
∗ Downloading and installing deno...
Archive:  /home/wschenk/.asdf/installs/deno/1.6.3/bin/deno.zip
  inflating: /home/wschenk/.asdf/installs/deno/1.6.3/bin/deno  
The installation was successful!

Selecting a version to use

There are 3 different scopes for usage:

globalwritten into ~/.tool-version, the default unless overridden
shellthe version that the current shell defaults to
localwritten into $PWD/.tool-version, overridden by directory

In our case, I'm going to do

asdf global deno 1.6.3

Then

deno --version
deno 1.6.3 (release, x86_64-unknown-linux-gnu)
v8 8.8.294
typescript 4.1.3

Conclusion

There seems to be a lot less shell overhead when using asdf vs rbenv and all the other ones, so I found that in practice it really sped up my system when running something that created a lot of subshells (./configure for example.)

Read next