asdf: A Versatile Version Manager

Overview

asdf is a powerful tool designed to manage multiple versions of programming languages, frameworks, and tools, allowing users to switch seamlessly between them. It supports a wide range of languages, including Python, NodeJS, Ruby, and more. This makes it an invaluable resource for developers who work with multiple technologies. asdf is compatible with macOS, Linux, and the Windows Subsystem for Linux, making it accessible to a broad audience.

Installation

To install asdf, you first need to determine the most recent tagged version from the asdf GitHub repository. Once you have identified the latest release, you can clone the corresponding branch into the $HOME/.asdf/ directory. For example, if the latest release is v1.2.3, you would execute the following command:

$ git clone \
    https://github.com/asdf-vm/asdf.git \    #1
    $HOME/.asdf \                             #2
    --branch v1.2.3                           #3
#1 The asdf repository on GitHub
#2 The destination for the cloned code
#3 The version of the code to use

After cloning the repository, you need to ensure that asdf is sourced during your shell's startup. For macOS users, where the default shell is zsh, you should add the following lines to your $HOME/.zshrc file. If you are using bash, add them to your $HOME/.bash_profile:

if [ -f $HOME/.asdf/asdf.sh ]; then
    source $HOME/.asdf/asdf.sh
fi

Once you have saved your startup file, open a new shell session and verify that asdf was installed correctly by running:

$ asdf --version

The output should display a version number that matches the branch you checked out when cloning the repository.

Installing and Managing Python Versions

With asdf installed, you can now add the Python plugin using the following command:

$ asdf plugin add python

This command makes the Python plugin available immediately. To verify that the plugin is working and to see which versions of Python are available, use:

$ asdf list all python

This command will list several hundred versions, including PyPy, Anaconda, and others. The standard CPython implementation versions are listed as numbers without any additional names. This flexibility allows developers to easily switch between different Python versions as needed for their projects.

FAQ (Frequently asked questions)

Is asdf compatible with macOS?

Can asdf be used on Linux?

Does asdf work with the Windows subsystem for Linux?