bin^2

bin^2

discord server
twitter

asdf-vm is a command-line tool for managing multiple language runtime versions on a per-project basis.

asdf-vm - A command-line tool for managing multi-language runtime versions on a per-project basis#

article/done/published#

Tools#

asdf-vm is a command-line tool for managing multi-language runtime versions on a per-project basis. It is similar to other command-line version management tools like rvm for Ruby and nvm for Node, but it supports multiple languages through an extensible plugin system architecture. The current list of plugins includes various languages as well as tools like Bazel or tflint that may require managing their runtime versions for each project.

Features of asdf:

  • Supports Bash, Zsh, and Fish.

  • Supports runtime version management for almost all language platforms.

  • Simple plugin system for easy extension of new runtimes.

  • Maintains global default configuration in a single configuration file.

  • Allows separate configuration for each project through a .tool-versions file.

Installation#

asdf supports multiple platforms and installation management tools. Taking macOS and brew as an example:

  • Install dependencies
brew install coreutils curl git
  • Install asdf
brew install asdf

View supported plugins#


asdf plugin list all | grep nodejs

Usage#

Using nodejs as an example:

View the installation instructions for the plugin. Different plugins have different dependencies that need to be configured separately.

  • Install dependencies
brew install coreutils

brew install gpg

asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git


bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'

  • List all versions
asdf list all nodejs
  • Install a specific version
asdf install nodejs latest
  • View installed versions
asdf list nodejs
  • Set the version to use
asdf global nodejs 15.4.0    # Global setting, saves the version to $HOME/.tool-versions

asdf shell nodejs 15.4.0     # Session setting, saves the version to the environment variable ASDF_${LANG}_VERSION

asdf local nodejs 15.4.0     # Local setting, saves the version to $PWD/.tool-versions
  • Use the current version
asdf exec node -v

Using asdf-direnv#

By default, using asdf requires the command asdf exec. If you want to use it without the command, you need to install the asdf-direnv plugin.

First, install direnv

curl -sfL https://direnv.net/install.sh | bash

echo 'eval "$(direnv hook zsh)"'>>~/.zshrc

Install asdf-direnv


asdf plugin-add direnv
asdf install direnv latest

asdf global direnv `asdf list direnv latest`

mkdir -p ~/.config/direnv/ && touch ~/.config/direnv/direnvrc

echo 'source "$(asdf direnv hook asdf)"' >> ~/.config/direnv/direnvrc

Project configuration

touch .envrc

echo 'use asdf' >> .envrc

direnv allow

Now you can use it directly

node -v
  • View the current version
asdf current nodejs

  • Remove a version
asdf uninstall nodejs 15.4.0

References#

Official website: https://asdf-vm.com/#/

Plugin list: https://asdf-vm.com/#/plugins-all?id=plugin-list

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.