Elixir 13.4 not working on fresh Windows installation

Background

I have a fresh Windows 10 VM, which I am trying to use to develop some Elixir code.
However I cannot even fetch the dependencies as an error occurs:

> mix deps.get

11:47:57.487 [error] beam\beam_load.c(86): Error loading module 'Elixir.Code.Formatter':
  lambda already defined for label 749. To fix this, please recompile this module with an OTP 25 compiler.



11:47:57.487 [error] Loading of c:/Program Files (x86)/Elixir/lib/elixir/ebin/Elixir.Code.Formatter.beam failed: :badfile

** (UndefinedFunctionError) function Code.Formatter.locals_without_parens/0 is undefined (module Code.Formatter is not available)
    (elixir 1.13.4) Code.Formatter.locals_without_parens()
    (elixir 1.13.4) lib/code/normalizer.ex:22: Code.Normalizer.normalize/2
    (elixir 1.13.4) lib/code.ex:1107: Code.quoted_to_algebra/2

Setup

The first thing I did was to install erlang OTP 25:

And then I went to Elixir’s page and installed Elixir 13.4 for Windows:

In my powershell, this is what I see when I check for both versions:

Elixir version

> iex.bat -v
IEx 1.13.4 (compiled with Erlang/OTP 22)
IEx 1.13.4 (compiled with Erlang/OTP 22)

Erlang version

> erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().'  -noshell
"25"

So it is fair to assume both installations are correct.

I also know that v1.13.4 is compatible with OTP 25:

https://bobs-list.kobrakai.de/elixir#version_v1.13

Questions

But clearly something is missing. I see the version I downloaded was compiled with OTP 22, but I find this very odd, as I used to have this exact same project working with OTP 24, on Windows.

> iex.bat -v
IEx 1.13.4 (compiled with Erlang/OTP 22)
2> erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().'  -noshell
"24"
> mix deps.get
Could not find Hex, which is needed to build dependency :credo
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] Y

How can I fix the error?

I don’t know how it looks on Windows, but for me it looks like you have installed Elixir precompiled for Erlang version 22. Are you able to choose exact version in Elixir installer? On Linux when using asdf I’m just installing Elixir version 1.13.4-otp-25 and everything works.

Edit: If I understand Elixir’s Windows installer code properly then it installs a Precompiled.zip from Elixir’s releases which as far as I remember is always compiled for lowest supported Erlang version (here 22).

Also there is a note:

This release has been verified to work with Erlang/OTP 25 RC2.

Source: Release v1.13.4 · elixir-lang/elixir · GitHub

Finally Erlang version 25 is not listed as officially supported in Elixir’s documentation, see:
https://hexdocs.pm/elixir/1.13.4/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp

That’s same even for Elixir version 1.14.0-dev:
https://hexdocs.pm/elixir/main/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp

Edit: Here is a José Valim comment on similar report:

You are using a precompiled Elixir version. It is just a matter of time until we have precompiled versions for OTP 25. It is usually tackled automatically by build tools. You can also compile it yourself.

Source: Support Erlang/OTP 25 new features · Issue #11220 · elixir-lang/elixir · GitHub

2 Likes

I agree with @Eiji; likely the precompiled version of Elixir isn’t built against Erlang 25. To check try uninstalling Erlang and install Erlang 24 and see what happens.

I removed Erlang OTP 25 and replaced it with OTP 24.
It seems to work fine for the time being, so I will keep it for now until the official version for Windows (the one that comes with the installer) is compatible with 25.