Skip to main content

Setting Up Elixir/Erlang Github Actions Using .tool-versions

· 2 min read

asdf is my number 1 go-to tooling version manager, and anyone that isn't a convert has not experienced the horror that is Python package managers. I stand steadfast with my hot take that any and every project should use asdf to fend off the "works on my machine" issues.

And what better way to use it than in a Github Action?

To generate a .tool-versions, you'll want to run the following:

# list down your desired version ids
$ asdf list all elixir | grep 1.16
$ asdf install elixir 1.16.1-otp-26
$ asdf local elixir 1.16.1-otp-26

# install erlang as well
$ asdf list all erlang | grep 26
$ asdf install erlang 26.2.2
$ asdf local erlang 26.2.2

These commands should result in a .tool-versions file being generated in your working directory, looking something like this:

erlang 26.2.2
elixir 1.16.1-otp-26

And any calls to either erl or elixir -v will result in the correct version showing up. Simple innit?

Actually using the .tool-versions file is dead simple when using the erlef/setup-beam@v1 action:

- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
version-file: .tool-versions
version-type: strict

And you're done! No need to fiddle around with manually specifying Elixir versions bla bla bla. Leave the boring manual work to the machines, I say.