Setup asdf & direnv – DEV Community

ASDF Model Supervisor

asdf is a software model supervisor. All software model definitions are contained inside one file (.tool-versions) which you’ll be able to test in to your mission’s Git repository to share along with your workforce, making certain everyone seems to be utilizing the very same variations of instruments.


Set up asdf

  • Ensure you have curl and git put in.
  • Obtain asdf with

    git clone ~/.asdf --branch v0.10.0
  • If you’re utilizing bash, add the next to your ~/.bashrc file:

    . $HOME/.asdf/
    # configure completions
    . $HOME/.asdf/completions/asdf.bash
  • If you’re utilizing zsh, add the next to your ~/.zshrc file:

    . $HOME/.asdf/
    # if utilizing oh-my-zsh, add `asdf` to your plugins checklist
    # for instance: plugins=(... asdf ...)
    # if you're not utilizing oh-my-zsh, add the next to your `.zshrc` file:
    # append completions to fpath
    fpath=(${ASDF_DIR}/completions $fpath)
    # initialise completions with ZSH's compinit
    autoload -Uz compinit && compinit

Set up plugins

After putting in asdf, add all of the plugins discovered within the .tool-versions file. This depends upon the instruments outlined in your .tool-versions file relying on the repository.

# Add all of the plugins to asdf.
cat .tool-versions | awk '{print $1}' | xargs -I _ asdf plugin add _

# Set up all instruments in response to .tool-versions.
asdf set up
Enter fullscreen mode

Exit fullscreen mode


In case your mission’s .tool-versions file comprises the next:

ruby 2.6.3
python 3.10.4
nodejs 16.0.0
Enter fullscreen mode

Exit fullscreen mode

Then you possibly can set up all of the instruments with their specified variations by working asdf set up.

International software variations

Optionally, you possibly can add the next .tool-versions file to your private home listing:

direnv 2.31.0
nodejs 16.13.2
pnpm 7.1.5
java adoptopenjdk-8.0.272+10
minikube 1.25.1
helm 3.6.3
helmfile 0.139.9
kubectl 1.23.3
kubespy 0.6.0
kubectx 0.9.4
jq 1.6
golang 1.15.15
poetry 1.1.13
Enter fullscreen mode

Exit fullscreen mode

!!! Notice
Ensure you keep updated with the newest or steady variations of instruments.

Check with official asdf documentation for extra info.


direnv is an extension on your shell. It augments current shells with a brand new function that may load and unload setting variables relying on the present listing.

Setup any mission with direnv by making a .envrc file that appears like the next:

#!/usr/bin/env bash
export DEBUG="*"

cat <<EOF >.env
Enter fullscreen mode

Exit fullscreen mode

Hook asdf with direnv


  • Set up asdf-plugin for direnv utilizing the next:

    asdf plugin-add direnv
  • Setup shell

    # change --shell flag primarily based in your present shell (bash, zsh, fish, and so forth.)
    asdf direnv setup --shell zsh --version newest
  • As soon as direnv is attached, you possibly can run the next command on the foundation listing of your mission to replace your setting given that you’ve a .envrc file in your mission root.

    asdf direnv native

Creating non permanent environments

You possibly can create a short lived setting with out modifying .envrc or .tool-versions

# Enter a brand new shell having python and node
asdf direnv shell python 3.8.10 nodejs 14.18.2

# Simply execute a npx command below some node model
asdf direnv shell nodejs 14.18.2 -- npx create-react-app
Enter fullscreen mode

Exit fullscreen mode


Add a Comment

Your email address will not be published. Required fields are marked *