erlangelixirelixir-mixbeam

elixir - error loading module ranch_server - recompile this module with an 20 compiler


I'm trying to run an existing elixir project that works on my other computer, on a new computer (both are mac).

When I run iex -S mix I get:

iex -S mix
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]


11:47:52.651 [error] Loading of /Users/benjamin/vepo/api/_build/dev/lib/ranch/ebin/ranch_server.beam failed: :badfile


11:47:52.651 [error] beam/beam_load.c(1863): Error loading module ranch_server:
  This BEAM file was compiled for a later version of the run-time system than 20.
  To fix this, please recompile this module with an 20 compiler.
  (Use of opcode 164; this emulator supports only up to 159.)



11:47:52.657 [info]  Application ranch exited: :ranch_app.start(:normal, []) returned an error: shutdown: failed to start child: :ranch_server
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function :ranch_server.start_link/0 is undefined (module :ranch_server is not available)
            (ranch) :ranch_server.start_link()
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3
            (stdlib) supervisor.erl:314: :supervisor.init_children/2
            (stdlib) gen_server.erl:365: :gen_server.init_it/2
            (stdlib) gen_server.erl:333: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application ranch: :ranch_app.start(:normal, []) returned an error: shutdown: failed to start child: :ranch_server
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function :ranch_server.start_link/0 is undefined (module :ranch_server is not available)
            (ranch) :ranch_server.start_link()
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3
            (stdlib) supervisor.erl:314: :supervisor.init_children/2
            (stdlib) gen_server.erl:365: :gen_server.init_it/2
            (stdlib) gen_server.erl:333: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Benjamins-MacBook-Pro:api benjamin$

I think I need to recompile ranch_server.beam. How do I do that?


Solution

  • It looks like you need to install Erlang 21.0 or later. You're currently running version 20. What is the version on the machine that works?

    ASDF is useful for managing multiple versions of erlang on the same machine.

    Or if you just want to recompile the dependency, you could try

    mix do deps.clean ranch_server, deps.get, deps.compile