Table of contents

What is asdf?

ASDF is a tool version manager. It allows developers to manage multiple versions of different programming languages, runtimes, and other development tools on a single system.

Fun fact: The name "asdf" comes from the first four letters on the left side of your keyboard. Try finding them!

Homepage: https://asdf-vm.com/

Key Features

  1. Single Configuration File: ASDF uses a .tool-versions file to specify the versions of all tools used in a project.
  2. Version Control Friendly: The .tool-versions file can be committed to version control systems like Git, ensuring all team members use the same tool versions.
  3. Plugin-based Architecture: ASDF can be extended to support various tools through plugins.

How It Works

  1. Shell Integration: ASDF integrates with your shell (like Bash or Zsh) to intercept commands.
  2. Plugins: Each tool (like Python, Node.js, etc.) is managed by a plugin.
  3. Shims: When you install a tool version, ASDF creates shims for its executables.
  4. Version Selection: When you run a command, ASDF checks the .tool-versions file and executes the specified version of the tool.

Advantages over Traditional Methods

  1. Consistency: Ensures all developers use the same tool versions, reducing "it works on my machine" issues.
  2. Simplicity: One tool to manage all version-specific dependencies, instead of using multiple version managers.
  3. Project-specific Configurations: Different projects can use different tool versions without conflicts.
  4. Automatic switching: You don't need to manually activate/deactivate environments as you switch between projects.

Example scenario

Let's say you have Python 3.8 and 3.9 installed via asdf, and your project's .tool-versions specifies Python 3.9.5.

  1. You cd into your project directory.
  2. You type python in the terminal.
  3. The asdf shim for Python is executed.
  4. Asdf reads the .tool-versions file.
  5. It sees that Python 3.9.5 is specified for this project.
  6. Asdf then runs the Python 3.9.5 executable.

This process happens transparently and quickly, so it feels like you're just running Python normally.

Installing asdf on Ubuntu: A Step-by-Step Guide

Prepare Your System: First, ensure your system is up-to-date:

$ sudo apt update && sudo apt upgrade

Install required dependencies:

$ sudo apt install curl git

Install asdf:

$ cd ~ && git clone https://github.com/asdf-vm/asdf.git ~/.asdf

Add the following to ~/.bashrc or ~/.zshrc:

. "$HOME/.asdf/asdf.sh"

Restart your shell or source the configuration file

Verify installation:

$ asdf --version

Using asdf on Ubuntu: A Step-by-Step Guide

Add a plugin:

$ asdf plugin add  []
# asdf plugin add nodejs

List All Available Versions:

$ asdf list all 
# asdf list all nodejs

Install a version:

$ asdf install  
# asdf install nodejs 18.0.0

List Installed Versions:

$ asdf list 
# asdf list nodejs

Set a local version (in current directory):

$ asdf local  
# asdf local nodejs 18.0.0

local writes the version to $PWD/.tool-versions, creating it if needed.

 

Greetings! Thank you for reading an article titled ASDF - The Multiple Runtime Version Manager which has been authored by Le Huan Vu. In case you wish to gather more insights about the author, you may consider visiting .