Skip to main content

How to set up asdf on MacOs

·2 mins

Being a software engineer today trends more and more to you becoming a polyglot. While I do not have a solution to make master a new language in 5 days I can provide something I found that has helped me immensly working with different languages.

The issue I faced was I had to install various languages for either work, courses or purley out of interest. While seemingly not an issue, after enough time my .zshrc file became littered with different version managers requiring me to troubleshoot and configure and when the occasion arised look up the commands to configure.

Previously I had about 40 lines in my zshrc deticated to different version managers such as nvm, pyenv + pyenv virtualenv, miniconda and rbenv. Now I have cleared 95% of that to two lines (see below).

# asdf
. /usr/local/opt/asdf/libexec/asdf.sh
. ~/.asdf/plugins/java/set-java-home.zsh

How to install #

You can install the tool using homebrew then adding flie to your .zshrc.

brew install asdf
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc

Make sure you note which languages you have installed and appropriate versions. Then uninstall them according to the docs.

Add a language #

Adding a language follows the below steps:

asdf plugin add <language>
asdf install <language> <version>
asdf global <language> <version>
  1. To see all available languages use asdf plugin list all. But most likley they will have the language you’re looking for. As an example let’s say we want to install Python. asdf plugin add python would be our command.
  2. To see what versions are available we run asdf list-all python. I was running 3.9 so we can enter asdf python latest:3.9.
  3. Finally we can set it to our global or default version with asdf global python latest:3.9. And you’re done!

Also here are two other helpful commands.

asdf plugin-update --all: update every language plugin.

asdf plugin list: show all local language plugins.

Hope you find this tool as helpful as I did.