DEV Community

Cover image for asdf Basics & Cheat Sheet
Tanmay Jain
Tanmay Jain

Posted on

asdf Basics & Cheat Sheet

One tool to rule them all.

asdf is a tool version manager. Manage each of your project runtimes with a single CLI tool and command interface.

Features:

  • Large ecosystem of existing runtimes & tools. Simple API to add support for new tools as you need!
  • Support for existing config files .nvmrc, .node-versions, .ruby-version for smooth migration!
  • .tool-versions to manage all your tools, runtimes and their versions in a single, sharable place.
  • Supports Bash, ZSH, Fish & Elvish with completions available.
  • Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows.

Install ASDF

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
Enter fullscreen mode Exit fullscreen mode

Add to ~/.bashrc

. $HOME/.asdf/asdf.sh
Enter fullscreen mode Exit fullscreen mode
. $HOME/.asdf/completions/asdf.bash
Enter fullscreen mode Exit fullscreen mode

Basic commands

  • Update asdf
asdf update
Enter fullscreen mode Exit fullscreen mode
  • Add plugin (eg.: ruby)
asdf plugin add ruby
Enter fullscreen mode Exit fullscreen mode
  • List all languages plugin:
asdf plugin list
Enter fullscreen mode Exit fullscreen mode

or

asdf plugin list --urls
Enter fullscreen mode Exit fullscreen mode
  • Update plugins
asdf plugin update --all
Enter fullscreen mode Exit fullscreen mode

or

asdf plugin update ruby
Enter fullscreen mode Exit fullscreen mode
  • Remove plugin
asdf plugin remove ruby
Enter fullscreen mode Exit fullscreen mode
  • List all possible ruby versions
asdf list-all ruby
Enter fullscreen mode Exit fullscreen mode
  • Install a ruby version using ruby plugin
asdf install ruby 3.0.0
Enter fullscreen mode Exit fullscreen mode
  • List all installed ruby versions
asdf list ruby
Enter fullscreen mode Exit fullscreen mode
  • Check current version of language plugin
asdf current ruby
Enter fullscreen mode Exit fullscreen mode
  • Check current version of all languages plugin
asdf current
Enter fullscreen mode Exit fullscreen mode
  • Check installation path of plugin version
asdf where
Enter fullscreen mode Exit fullscreen mode
  • Change plugin version locally/globally
asdf local ruby 3.0.0
Enter fullscreen mode Exit fullscreen mode

or

asdf global ruby 2.7.2
Enter fullscreen mode Exit fullscreen mode

Remove asdf

  • Remove following from ~/.bashrc
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
Enter fullscreen mode Exit fullscreen mode
  • Run:
rm -rf ${ASDF_DATA_DIR:-$HOME/.asdf} ~/.tool-versions
Enter fullscreen mode Exit fullscreen mode

Top comments (0)