Building Elixir Projects




Some time back I’d inquired about official support for Elixir and/or Erlang. It wasn’t supported at the time, and it’s still not official, but hopefully if more folks raise their hands in support of the idea, we’ll get it added!

In the meantime, here’s the pertinent details of our circle.yml that we’ve been using to get our elixir projects building. I hope we can share our experiences and make it easy for anyone else to come along and start building elixir here at Circle without excessive Googling and experimentation :smile:

    PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"

    - ~/.asdf
    - if ! asdf | grep version; then git clone ~/.asdf; fi
    - asdf plugin-add erlang
    - asdf plugin-add elixir
    - erlang_version=$(awk '/erlang/ { print $2 }' .tool-versions) && asdf install erlang ${erlang_version}
    - elixir_version=$(awk '/elixir/ { print $2 }' .tool-versions) && asdf install elixir ${elixir_version}
    - yes | mix deps.get
    - mix test --no-start

Although it might look a little bit much, it’s fairly straightforward:

  1. For a generic language installer/package manager, we’re using ASDF. The lines above will:
    a. Install ASDF itself into ~/.asdf.
    b. Install the Erlang and Elixir plugins for ASDF.
    c. Install Erlang and Elixir according to the versions specified in .tool-versions.
  2. Add locations to $PATH so mix, etc., can be used.
  3. Specify additional directories to cache so ASDF, Elixir, and Erlang won’t need to be fetched and installed on future runs.
  4. Install Elixir dependencies with mix.
  5. Run Elixir tests via mix, but do not start the application automatically.



Thanks so much for sharing this Scott! I am sure it will be useful for anyone trying to use Elixir on CircleCI.

You also win the prize for best first post to a new community ever. :tada:


Hi goneflyin,
Thanks for posting your setup! I found it a while back and have been using it happily ever since.

@CircleCI: Will there ever be official support for Erlang/Elixir? I’d really like to shrink my circle.yml if possible.


Thanks for this! We’ve expanded on it a bit for use with the elixir buildpack and dependency caching:


Thanks for this - it’s helped us a lot with one of our Elixir projects.

A word of warning though - piping yes into mix could be dangerous. I was piping it into mix deps.compile, and it was causing my circle builds to fail because they hit 4GB of memory. Seems like elixir just caches all the input coming in from stdin, and it doesn’t take long to build up a ton of input…

I’ve ended up explicitly calling mix local.hex --force and mix local.rebar --force instead of using yes


I tried using --force instead of pipng yes, but got this:

mix deps.get --force
Could not find Hex, which is needed to build dependency :phoenix

Shall I install Hex? [Yn] 

the build was canceled (by me)

Just realized I was using a different mix command so maybe that’s why.

Btw, it looks like there are more folders to consider caching:


I was suggesting using --force with mix local.hex --force which does the same thing as that prompt you are getting in mix deps.get.

I also cache a few more folders. My dependencies section looks like this now:

    - if ! asdf | grep version; then git clone ~/.asdf; fi
    - asdf plugin-add erlang
    - asdf plugin-add elixir
    - erlang_version=$(awk '/erlang/ { print $2 }' .tool-versions) && asdf install erlang ${erlang_version}
    - elixir_version=$(awk '/elixir/ { print $2 }' .tool-versions) && asdf install elixir ${elixir_version}
    - mix local.hex --force
    - mix local.rebar --force
    - mix deps.get
    - mix deps.compile
    - ~/.asdf
    - ~/.mix
    - deps
    - _build

Add support for Elixir/Erlang

Thanks for the update and clarification.

It still seems like my mix test step is compiling more than it should need to, but the build time is down to 2 minutes, so it’s not horrible.

I did get a message that said:

circle.yml specified cache directories: /home/ubuntu/.mix but they don't exist


I had a problem with solutions here and --force didn’t help:

mix local.hex --force returned exit code 255

No version set for elixir Action failed: mix local.hex --force

and I found another way which started working after a few tiny changes. In case anyone will be looking for alternative, check this gist:


I ran into issues with asdf plugin-add where if the plugin was already added the build would error.

These updated lines worked to get the build going again:

    - if ! asdf plugin-list | grep erlang; then asdf plugin-add erlang; fi
    - if ! asdf plugin-list | grep elixir; then asdf plugin-add elixir; fi

Thanks for putting this all out there. I just found asdf the other day and considered switching from our big -ol prepare script. This is much cleaner. I appreciate it!


I had a problem with the suggestions in this thread, where awk would error out:

circle ci fatal: cannot open file `.tool-versions' for reading

Anyone else see that? Am I just being dim?


Add these before awk & install commands.

   - echo "erlang 18.2.1" >> .tool-versions
   - echo "elixir 1.2.5" >> .tool-versions

This is my fully working config:


Thanks @jc00ke. I ran into that issue as well, and should’ve looked here first.

Here is essentially the same solution to the issue I opened on GitHub:

Regarding awk, the maintainers of asdf also pointed out that asdf install by itself is enough. It will read the .tool-versions file for you.

I’ve been experimenting with the official Docker container for Elixir as an alternative to asdf for testing, but I haven’t got it working yet. The Docker container uses precompiled binaries, but on the other hand CircleCI doesn’t yet have a great solution for caching or testing with Docker containers.


We build our own Docker containers when releasing, and though we have Docker containers for development I personally stay away from them. My goal in the future is to run CI with the container though, since we’re deploying with containers.

Our “devops” developer is handling most of that though, so… ¯_(ツ)_/¯


asdf is working okay now so we’ll probably stick with that for now.

I started looking at a self-hosted copy of (in a Docker container) as an alternative to Circle. It’s built from the ground up for Docker.


Thank you for sharing this @goneflyin.

The feature request topic for native Erlang/Elixir support is this one: Add support for Elixir/Erlang

I guess it would be valid to vote/like for the native support, maybe we can bring some attention to it with more people.


Here’s a recently updated article for Elixir on Circle:


I haven’t been able to get Erlang 19.0.2 to work on CircleCI with asdf. Does anyone have CircleCI working with Erlang 19 (with asdf or otherwise)?


I just went through the process for my Phoenix app (Erlang 19.0.2, Elixir 1.3.2) and wrote out all the steps. It currently builds in CircleCI and the test output is decently integrated.