Elixir elixir 1.16.2-otp-26 IEX session fails to start

I’m using asdf as a package version manager on macOS M1.
After installing the latest 1.16.2 version and setting it on a dummy project, IEX session fails to start up and raises the error:

todo_app iex
Erlang/OTP 25 [erts-13.2.2.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

*** ERROR: Shell process terminated! (^G to start new job) ***
=ERROR REPORT==== 28-Mar-2024::13:04:21.374567 ===
beam/beam_load.c(1001): Error loading function 'Elixir.Enum':count_until/2: op i_bif2_body: ssbd:
  import 16 not a BIF


=ERROR REPORT==== 28-Mar-2024::13:04:21.374652 ===
Loading of /Users/serguei/.asdf/installs/elixir/1.16.2-otp-26/bin/../lib/elixir/ebin/Elixir.Enum.beam failed: badfile

=ERROR REPORT==== 28-Mar-2024::13:04:21.374681 ===
Error in process <0.84.0> with exit value:
{undef,[{'Elixir.Enum',reduce_while,
                       [[iex],{ok,[]},#Fun<Elixir.Application.0.84698129>],
                       []},
        {'Elixir.IEx','-start/2-fun-1-',2,[{file,"lib/iex.ex"},{line,882}]}]}


BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

When checking the Elixir version in the Terminal, it drops much more errors:

elixir -v
=ERROR REPORT==== 28-Mar-2024::13:10:29.689329 ===
beam/beam_load.c(190): Error loading module 'Elixir.Kernel':
  This BEAM file was compiled for a later version of the runtime system than the current (Erlang/OTP 25).
  To fix this, please re-compile this module with an Erlang/OTP 25 compiler.
  (Use of opcode 182; this emulator supports only up to 180.)


=ERROR REPORT==== 28-Mar-2024::13:10:29.689340 ===
Loading of /Users/serguei/.asdf/installs/elixir/1.16.2-otp-26/bin/../lib/elixir/ebin/Elixir.Kernel.beam failed: badfile

=ERROR REPORT==== 28-Mar-2024::13:10:29.694766 ===
beam/beam_load.c(190): Error loading module elixir_code_server:
  This BEAM file was compiled for a later version of the runtime system than the current (Erlang/OTP 25).
  To fix this, please re-compile this module with an Erlang/OTP 25 compiler.
  (Use of opcode 181; this emulator supports only up to 180.)


=ERROR REPORT==== 28-Mar-2024::13:10:29.694769 ===
Loading of /Users/serguei/.asdf/installs/elixir/1.16.2-otp-26/bin/../lib/elixir/ebin/elixir_code_server.beam failed: badfile

=SUPERVISOR REPORT==== 28-Mar-2024::13:10:29.694827 ===
    supervisor: {local,elixir_sup}
    errorContext: start_error
    reason: {'EXIT',
                {undef,
                    [{elixir_code_server,start_link,[],[]},
                     {supervisor,do_start_child_i,3,
                         [{file,"supervisor.erl"},{line,420}]},
                     {supervisor,do_start_child,2,
                         [{file,"supervisor.erl"},{line,406}]},
                     {supervisor,'-start_children/2-fun-0-',3,
                         [{file,"supervisor.erl"},{line,390}]},
                     {supervisor,children_map,4,
                         [{file,"supervisor.erl"},{line,1256}]},
                     {supervisor,init_children,2,
                         [{file,"supervisor.erl"},{line,350}]},
                     {gen_server,init_it,2,
                         [{file,"gen_server.erl"},{line,851}]},
                     {gen_server,init_it,6,
                         [{file,"gen_server.erl"},{line,814}]}]}}
    offender: [{pid,undefined},
               {id,elixir_code_server},
               {mfargs,{elixir_code_server,start_link,[]}},
               {restart_type,permanent},
               {significant,false},
               {shutdown,2000},
               {child_type,worker}]

=CRASH REPORT==== 28-Mar-2024::13:10:29.695062 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.80.0>
    registered_name: []
    exception exit: {{shutdown,
                      {failed_to_start_child,elixir_code_server,
                       {'EXIT',
                        {undef,
                         [{elixir_code_server,start_link,[],[]},
                          {supervisor,do_start_child_i,3,
                           [{file,"supervisor.erl"},{line,420}]},
                          {supervisor,do_start_child,2,
                           [{file,"supervisor.erl"},{line,406}]},
                          {supervisor,'-start_children/2-fun-0-',3,
                           [{file,"supervisor.erl"},{line,390}]},
                          {supervisor,children_map,4,
                           [{file,"supervisor.erl"},{line,1256}]},
                          {supervisor,init_children,2,
                           [{file,"supervisor.erl"},{line,350}]},
                          {gen_server,init_it,2,
                           [{file,"gen_server.erl"},{line,851}]},
                          {gen_server,init_it,6,
                           [{file,"gen_server.erl"},{line,814}]}]}}}},
                     {elixir,start,[normal,[]]}}
      in function  application_master:init/4 (application_master.erl, line 142)
    ancestors: [<0.79.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.81.0>,normal}]
    links: [<0.79.0>,<0.44.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 1598
    stack_size: 28
    reductions: 273
  neighbours:

=INFO REPORT==== 28-Mar-2024::13:10:29.697139 ===
    application: elixir
    exited: {{shutdown,
                 {failed_to_start_child,elixir_code_server,
                     {'EXIT',
                         {undef,
                             [{elixir_code_server,start_link,[],[]},
                              {supervisor,do_start_child_i,3,
                                  [{file,"supervisor.erl"},{line,420}]},
                              {supervisor,do_start_child,2,
                                  [{file,"supervisor.erl"},{line,406}]},
                              {supervisor,'-start_children/2-fun-0-',3,
                                  [{file,"supervisor.erl"},{line,390}]},
                              {supervisor,children_map,4,
                                  [{file,"supervisor.erl"},{line,1256}]},
                              {supervisor,init_children,2,
                                  [{file,"supervisor.erl"},{line,350}]},
                              {gen_server,init_it,2,
                                  [{file,"gen_server.erl"},{line,851}]},
                              {gen_server,init_it,6,
                                  [{file,"gen_server.erl"},{line,814}]}]}}}},
             {elixir,start,[normal,[]]}}
    type: temporary

{"init terminati=INFO REPORT==== 28-Mar-2024::13:10:29.697265 ===
    application: compiler
    exited: stopped
    type: temporary

ng in do_boot",{{badmatch,{error,{elixir,{{shutdown,{failed_to_start_child,elixir_code_server,{'EXIT',{undef,[{elixir_code_server,start_link,[],[]},{supervisor,do_start_child_i,3,[{file,"supervisor.erl"},{line,420}]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,406}=ERROR REPORT==== 28-Mar-2024::13:10:29.697304 ===
Error in process <0.9.0> with exit value:
{{badmatch,
     {error,
         {elixir,
             {{shutdown,
                  {failed_to_start_child,elixir_code_server,
                      {'EXIT',
                          {undef,
                              [{elixir_code_server,start_link,[],[]},
                               {supervisor,do_start_child_i,3,
                                   [{file,"supervisor.erl"},{line,420}]},
                               {supervisor,do_start_child,2,
                                   [{file,"supervisor.erl"},{line,406}]},
                               {supervisor,'-start_children/2-fun-0-',3,
                                   [{file,"supervisor.erl"},{line,390}]},
                               {supervisor,children_map,4,
                                   [{file,"supervisor.erl"},{line,1256}]},
                               {supervisor,init_children,2,
                                   ]},{su[{file,"supervisor.erl"},{line,350}]},
                               {gen_server,init_it,2,
                                   [{file,"gen_server.erl"},{line,851}]},
                               {gen_server,init_it,6,
                                   [{file,"gen_server.erl"},{line,814}]}]}}}},
              {elixir,start,[normal,[]]}}}}},
 [{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,198}]},
  {init,start_em,1,[]},
  {init,do_boot,3,[]}]}

pervisor,'-start_children/2-fun-0-',3,[{file,"supervisor.erl"},{line,390}]},{supervisor,children_map,4,[{file,"supervisor.erl"},{line,1256}]},{supervisor,init_children,2,[{file,"supervisor.erl"},{line,350}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]}]}}}},{elixir,start,[normal,[]]}}}}},[{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,198}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({{badmatch,{error,{elixir,{_}}}},[{elixir,start_cli,0,[{_},{_}]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done

Here is the list of the installed Elixir versions when running asdf list elixir :

  1.15.6-otp-25
  1.16.0-otp-25
  1.16.1-otp-26
 *1.16.2-otp-26

When switching back to 1.16.0-otp-25, it works without errors:

asdf local elixir 1.16.0-otp-25
➜  todo_app iex
Erlang/OTP 25 [erts-13.2.2.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Interactive Elixir (1.16.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

Any ideas about this issue?

You have to match with the version of Erlang installed. You have 25 so you need to install Elixir 1.16.2-otp-25.

Technically it doesn’t need to be a match, but any version matching or lower than the installed otp version is expected to work. It’s better to match the versions though.

Well, I believed that setting just the elixir version on a project would be enough.
So my .tool-versions contained just the elixir version:

elixir 1.16.2-otp-26

Then when being in the project path, I checked the versions:

asdf list elixir         
  1.15.6-otp-25
  1.16.0-otp-25
 *1.16.2-otp-26

asdf list erlang         
 *25.3.2.6
  26.2.3

This is how I discovered that the Erlang version also had to be set in the .tool-versions file.

So after setting it with asdf local erlang 26.2.3, everything came to normal.
Here is the final content of the .tool-versions file:

elixir 1.16.2-otp-26
erlang 26.2.3

Now elixir -v and iex -S mix work fine.
Thank you for your responses.

That’s not the case. elixir 1.16.2-otp-26 means install precompiled elixir, where elixir was precompiled using otp-26. Sometimes compiling elixir with a newer than minimally supported otp version does enable new features supported by that otp version within elixir.

This is completely separate from your local otp version.

If you don’t care for new features you can just use elixir 1.16.2 with asdf and it’ll default to elixir compiled with the minimal supported otp version.

1 Like