【问题标题】:elixir - error loading module ranch_server - recompile this module with an 20 compilerelixir - 错误加载模块 ranch_server - 使用 20 编译器重新编译此模块
【发布时间】:2020-02-23 07:32:04
【问题描述】:

我正在尝试在我的另一台计算机上运行现有的 elixir 项目,在新计算机上运行(两者都是 mac)。

当我运行 iex -S mix 我得到:

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$

我想我需要重新编译ranch_server.beam。我该怎么做?

【问题讨论】:

    标签: erlang elixir elixir-mix beam


    【解决方案1】:

    看来您需要安装 Erlang 21.0 或更高版本。您当前运行的是版本 20。可以运行的机器上的版本是什么?

    ASDF 对于在同一台机器上管理多个版本的 erlang 很有用。

    或者如果你只是想重新编译依赖,你可以试试

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

    【讨论】:

    • 谢谢。 Erlang 20 是正确的版本。我做了mix deps.clean --all 然后mix deps.get 来修复它,这与你的答案底部的原因基本相同。
    猜你喜欢
    • 2017-07-19
    • 2016-05-29
    • 2012-11-19
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 2015-07-07
    • 2022-09-27
    • 2019-01-27
    相关资源
    最近更新 更多