使用 exrm 时,生产环境找不到 OTP 模块:httpc

production env does not find OTP module :httpc when using exrm

我正在尝试为我的 phoenix-framework 项目创建一个版本。

一切正常,直到我的代码需要使用来自 OTP 的 :httpc 模块执行特定操作。

显然是 exrm,没有捆绑 httpc 模块,因此找不到它。

我已经尝试将它添加到我的 mix.exs 应用程序依赖项中,但是一旦我这样做,它就会拒绝创建一个版本,因为 "error"

有谁知道如何解决这个问题?

对于 mix.env 以 :httpc 作为依赖项:

$ MIX_ENV=prod mix release --verbosity=vebose                                                        
        Building release with MIX_ENV=prod.
        ==> Generating relx configuration...
        ==> Generating sys.config...
        ==> Generating boot script...
        ==> Packaging consolidated protocols...
        ==> Generating release...
        ===> Starting relx build process ...
        ===> Resolving OTP Applications from directories:
                  /home/morgan/Documents/rateapi/_build/prod/lib
                  /home/morgan/Documents/rateapi/deps
                  /usr/local/lib/elixir/bin/../lib/eex/ebin
                  /usr/local/lib/elixir/bin/../lib/elixir/ebin
                  /usr/local/lib/elixir/bin/../lib/ex_unit/ebin
                  /usr/local/lib/elixir/bin/../lib/iex/ebin
                  /usr/local/lib/elixir/bin/../lib/logger/ebin
                  /usr/local/lib/elixir/bin/../lib/mix/ebin
                  /home/morgan/Documents/rateapi/lib
                  /usr/erlang/otp_R18B03/lib/erlang/lib
                  /home/morgan/Documents/rateapi/rel
        ==> ERROR: "Failed to build release. Please fix any errors and try again."

对于没有 :httpc 依赖的 mix.env :

** (exit) an exception was raised:
    ** (UndefinedFunctionError) function :httpc.request/4 is undefined (module :httpc is not available)
        :httpc.request(:get, {'http://free.currencyconverterapi.com/api/v3/currencies', []}, [], [])
        (fx_rates) web/controllers/rate_controller.ex:46: FxRates.V1.RateController.reload_currencies/0
        (fx_rates) web/controllers/rate_controller.ex:66: FxRates.V1.RateController.show/2
        (fx_rates) web/controllers/rate_controller.ex:1: FxRates.V1.RateController.action/2
        (fx_rates) web/controllers/rate_controller.ex:1: FxRates.V1.RateController.phoenix_controller_pipeline/2
        (fx_rates) lib/phoenix/router.ex:261: FxRates.Router.dispatch/2
        (fx_rates) web/router.ex:1: FxRates.Router.do_call/2
        (fx_rates) lib/fx_rates/endpoint.ex:1: FxRates.Endpoint.phoenix_pipeline/1

您可能缺少 erlang-inets 包。尝试安装它或重新安装它。如果您正在使用 Ubuntu,您可以安装它:

sudo apt-get install erlang-inets

或者,您可能想尝试将模块 :inets 添加到您的 mix.exs 应用程序依赖项中。