Upgrading Elixir - how to check versions, delete, and upgrade?

Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questions.

I want to start of with the “latest and greatest” so that my questions when I get stuck are relevant. So

  1. What do I need and how do I get them

I think I need Elixir Erlang and Mix and possibly Hex

I have in the past installed all of these - so my file system is a bit of a historical mess - so

  • how do I find out which versions I already have?
  • how do I find out the latest versions?
  • how do do I update to the latest versions?
  • how do I delete old versions if they are not needed?

I realize I can find the answers to all these questions by Googling and experimentation but it would be very nice to find the answers “all in one place”

The “brew doctor” command is pretty good at flushing out old systems and telling me what to do - so it would be very nice if there was an equivalent command - let me daydream a bit:

> elixir doctor
Wow Joe you already have elixir installed
but it's a really old version ...
you might like to delete the old version with 'elixir 
and then do 'elixir upgrade'




Im a big fan of https://github.com/asdf-vm/asdf.
You can manage a multitude of language versions, including elixir and erlang and set up global or per project versions.


You can find out the current version using elixir --version or by just entering the REPL, iex, it will show you a nice banner about your Erlang and elixir environment.

Hex is usually kept up to date by mix. It will tell you when it needs an update and how you can update then.

How you update and remove Erlang and elixir dies massively depend on how you installed it originally. Also you may want or may not want to remove ~/.mix after you have removed elixir.


Welcome back Joe :039:

As @cpgo mentioned, it’s often beneficial to have multiple versions of languages installed as some projects may depend on different versions. For this we use an Elixir version manager (like ASDF).

As mention by @NobbZ, Mix is installed with Elixir.

If you use a language version manager then you may find you don’t need to uninstall older versions, but if you do the method will depend on which version manager you use.

I would recommend most people use a language version manager because you may need to work on older projects that are tied to older versions of languages. They are also used in production - so a server can host different apps using different versions of languages or frameworks. Some LVMs can even compartmentalise packages (such as Gems if you’re using a language such as Ruby) so that they are only loaded for that specific app/version (so are therefore more efficient/performant for the server).

Have a look here to see some of the version managers available for Elixir:

If you have any other questions or you’d rather not use a LVM, let us know how you have installed previous versions and we can help with how to remove them.


As you seem to be using homebrew you can use $ brew list FORMULA:

$ brew list elixir
/usr/local/Cellar/elixir/1.7.2/lib/eex/ (7 files)
/usr/local/Cellar/elixir/1.7.2/lib/elixir/ (231 files)
/usr/local/Cellar/elixir/1.7.2/lib/ex_unit/ (29 files)
/usr/local/Cellar/elixir/1.7.2/lib/iex/ (30 files)
/usr/local/Cellar/elixir/1.7.2/lib/logger/ (12 files)
/usr/local/Cellar/elixir/1.7.2/lib/mix/ (90 files)
/usr/local/Cellar/elixir/1.7.2/share/man/ (4 files)
$ brew list erlang
/usr/local/Cellar/erlang/21.0.5/lib/erlang/ (4393 files)
/usr/local/Cellar/erlang/21.0.5/share/doc/ (1261 files)

to upgrade simply follow the usual homebrew process:

$ brew update

and then

$ brew upgrade
$ elixir -v
Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.7.2 (compiled with Erlang/OTP 21)

For that command to work Erlang and Elixir have to be on the PATH. So in your ~/.bash_profile there should be something like:

export PATH=/usr/local/opt/openssl/bin:/usr/local/opt/erlang/bin:/usr/local/opt/elixir/bin:$PATH;


$ brew list --versions erlang
erlang 21.0 20.3.6 21.0.5 21.0.4 20.3.4
$ brew list --versions elixir
elixir 1.7.1 1.6.5 1.6.4 1.7.2 1.6.6
$ brew cleanup elixir
Removing: /usr/local/Cellar/elixir/1.6.4... (411 files, 5.4MB)
Removing: /usr/local/Cellar/elixir/1.6.5... (411 files, 5.4MB)
Removing: /usr/local/Cellar/elixir/1.6.6... (412 files, 5.4MB)
Removing: /usr/local/Cellar/elixir/1.7.1... (413 files, 5.5MB)
==> This operation has freed approximately 21.7MB of disk space.
$ brew cleanup erlang
Removing: /usr/local/Cellar/erlang/20.3.4... (7,036 files, 277.4MB)
Removing: /usr/local/Cellar/erlang/20.3.6... (7,036 files, 277.3MB)
Removing: /usr/local/Cellar/erlang/21.0... (5,668 files, 271.8MB)
Removing: /usr/local/Cellar/erlang/21.0.4... (5,668 files, 271.7MB)
==> This operation has freed approximately 1GB of disk space.

One more for asdf https://github.com/asdf-vm/asdf

If you want to remove all versions installed with brew and prevent it from installing again whenever you update brew, caution that this is non-reversible, brew uninstall <name> --force

For asdf, after installing and enabling it (first section on the GitHub page), you can do:

asdf plugin-add erlang

asdf plugin-add elixir

asdf install elixir 1.7.2

asdf install erlang 21.0.5

After you can do:

asdf list erlang

Or whatever plugin, to list the installed versions

asdf list-all erlang

To show all available versions (if new versions have been released between the time you installed the plugin, you need to update the plugin to show the new ones, with asdf plugin-update all or asdf plugin-update erlang)

asdf current

To show the current versions of all plugins, or asdf current erlang to just show the current set erlang version. If done from a directory that has a local version specified it will show the local version that is set, anywhere else it will show the global one

asdf uninstall <name> <version> to uninstall a specific one

To set the global versions to use

asdf global <name> <version>

And when you want to pin down a version to use on a project, from the directory of the project,

asdf local <name> <version>

To install hex, after having elixir installed

mix local.hex

And if you want to use phoenix tasks to generate phoenix projects/applications, mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez


If you do not want multiple versions and need a centralized point then this is where I periodically check: Elixir releases on GitHub.

For my dev work I only use the latest version because I would like to know if a breaking change manages to sneak itself in the older projects or, much more likely, a package is very outdated – and if I should refactor something in those older projects so that they are not left behind and are upgradable should the need arise.

For macOS, a single brew upgrade should be absolutely enough.

For Linux, this is how I setup my work VMs:

  1. Make a directory ~/bin (one of the first things I do on my Linux machines).
  2. Download the latest Precompiled.zip release from the link above.
  3. Make a directory ~/bin/elixir-x.y.z (replace with release version).
  4. Unzip Precompiled.zip in it.
  5. Add/replace ~/bin/elixir-x.y.z/bin to $PATH, usually in ~/.bashrc or ~/.bash_profile.
  6. Delete the older version of Elixir in the same directory.
  7. Restart your shell or just do source ~/.bashrc.
  8. Check with elixir -v. On Win10, mine prints out:
Erlang/OTP 21 [erts-10.0.1] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Elixir 1.7.2 (compiled with Erlang/OTP 19)
  1. Run these for good measure (they install / replace rebar and mix with their latest versions):
  • mix local.rebar --force
  • mix local.hex --force
  1. You should be good to go.

Of course, if you want the latest Elixir with the latest OTP, there are extra steps required – like compiling Elixir yourself, or using a language version manager (I think asdf allows you to specify which version of Erlang/OTP you want Elixir compiled against).

Any further questions, we will help.

1 Like

Hello Joe,

it’s always the same pain in digging back or generally in using different programming languages time by time. You’ll need to find the way back…

So this is my personal opinion and solution to your questions.

  1. What do I need and how do I get them

You’ll need Nix and a little .nix file and it’ll maybe solve the rest of your questions.
You’ll get it here: https://nixos.org/nix/download.html

The .nix file you’ll need - call it default.nix and put it into the root of your working project directory:

{ pkgs ? import <nixpkgs> {} }:
rec {
  elixir = pkgs.buildPackages.beam.packages.erlangR21.elixir_1_7;
  hex = pkgs.buildPackages.beam.packages.erlangR21.hex;
  rebar3 = pkgs.buildPackages.beam.packages.erlangR21.rebar3;

  locale = pkgs.buildPackages.glibcLocales;
  LANG = "en_US.utf8";

  env = pkgs.stdenv.mkDerivation rec {
    name = "env";
    inherit LANG rebar3;
    nativeBuildInputs = [locale elixir hex];
    shellHook = ''
      function cleanup() {
        rm -rf .mix
      trap cleanup EXIT

      mix local.rebar rebar3 $rebar3/bin/rebar3
      elixir --version

Then to get started in using the “latest” Elixir version you’ll only need to remember one command nix-shell -A env - and you’ll be sitting in a shell with Elixir.
If you really got the latest Elixir version is dependent on the up-to-dateness of Elixir within the Nix Packages Collection and of course your default.nix file.

how do I find out the latest versions?

It really is the easiest to visit: https://github.com/elixir-lang/elixir/releases

how do I delete old versions if they are not needed?

nix-collect-garbage -d

The main benefits why I’m working with & on this solution is I can lock the Nix Packages Collection to a certain version within my project and can be shure every one else working on the project can very easily use the exact same Erlang & Elixir version.
Of course maybe one of the other mentioned version managers can do the same, but I’m in need of a language independend and flexible solution.
By the way Nix has more then this arguments to deliver.

I know this is old but I’m here to not preach language version managers or anything and just offer the simplest most straightforward upgrade since you mentioned you are using homebrew?

Upgrading Elixir if it was installed with homebrew is pretty easy. Erlang is a dependency that will be installed or updated for you by homebrew as needed.

  1. brew update
  2. brew upgrade elixir
  3. elixir --version

(I never do brew upgrade without a specfic formula, as that has caused me many headaches in the past)

Happy Elixiring!


Any way to maintain multiple versions of Elixir on windows?

I’m sure there’s a thread somewhere about this but couldn’t find it with a quick search. I have a feeling you can sort-of do it with chocolatey, so perhaps that’s worth pursuing.

All that’s assuming you want native windows builds. If you’re willing & able to use wsl, then asdf works beautifully there.


So with the help of chocolatey, we can install all the dependencies of asdf?

No - choco can install win32 elixir for you, and although it’s not intended I think it’s possible to finagle it to install multiple versions. I don’t know the details though.

asdf is very unixy (I think it’s mostly shell scripts), so is never going to run natively in windows. But it works great in wsl.

[Edit - I think wsl is the best place for elixir in windows, unless you have very windows-specific requirements, like building a windows GUI app or building exe’s to run on windows servers]


Alright got it.

Yeah here also he mentioned that it won’t be possible.

I thought there might be some other way to maintain besides asdf :grin:
But anyways, thanks for clearing the doubt :slightly_smiling_face: