Tools

Tools: asdf

asdf is a tool version manager that integrates with your shell and automatically executes the correct tool version based on your configuration (which is specified in the .tool-versions file.)

The classic use case is that you want to seamlessly execute the correct tool version without futzing with your setup each time you switch projects. It’s a huge time saver and you can commit the .tool-versions file into source control for easy team coordination.

NOTE: asdf does not manage environment variables.

Resources

Official documentation: https://asdf-vm.com/

Fig has a useful quick reference: https://fig.io/manual/asdf

Concepts

Installing

This assumes you use Homebrew on a Mac (check the official doc for alternate approaches).

First install the dependencies (you may already have these):

And then install asdf itself:

Finally, integrate with your shell (zsh in my case):

Core

The asdf core only provides a framework for the execution of plugins. You will need to install a plugin for each tool that you wish to use.

A sample of the core asdf commands:

Plugins

For each tool that you wish to use through asdf you will need to install a plugin.

Some plugin commands:

Plugins I use

Add plugins using the asdf plugin add <name> <git-url> command.

Versions

Once a plugin is installed you will then need to install specific versions of that tool.

Some version commands:

Configuration

asdf will use the tool version specified in the .tool-versions file in the current directory. If the .tool-versions file does not exist in the current directory, or if there is no entry for the tool, asdf will cascade up the directory tree until it finds the first matching entry. If not matching entry is found, it will use the latest installed version of the tool.

In this way, the .tool-versions file in the root directory acts as a set of defaults. You can set the version by editing the .tool-versions file directly or using the asdf global <name> <version> command. You can tell asdf to use the latest installed tool version by using latest for the <version>.

You would normally have a .tool-versions file at the base of a project and this file should be committed to version control to ensure all team members are using the agreed version of the various tools.

asdf has the ability to use the system installed version of a tool by indicating system as the version. Of course, this only applies to tools that are installed using asdf. Tools that are not installed using asdf would naturally default to the system installed version.

Here is an example .tool-versions file:

# asdf tool versions
golang 1.21.1
hugo 0.119.0
nodejs 20.5.0
ruby 3.2.2

Tools

Web

Languages

Data