生产env没有找到OTP模块:使用exrm时的httpc

The*_*uad 5 erlang elixir exrm phoenix-framework

我正在尝试为我的凤凰框架项目创建一个版本.

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

显然exrm,没有捆绑httpc模块,因此无法找到它.

我试图将它添加到我的mix.exs应用程序依赖项中,但是一旦我这样做,就会因为"错误"而拒绝创建发布版本

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

对于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."
Run Code Online (Sandbox Code Playgroud)

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

** (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
Run Code Online (Sandbox Code Playgroud)

Sas*_*eca 11

你可能错过了erlang-inets包.尝试安装或重新安装.如果您使用的是Ubuntu,可以使用以下命令安装:

sudo apt-get install erlang-inets
Run Code Online (Sandbox Code Playgroud)

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

  • 当使用mix phoenix.server时,inets软件包已安装并正常运行...但是你的文章指出了我的解决方案,将模块:inets添加到我的mix.exs应用程序的依赖项中...编辑你的解决方案我会标记它被接受;-)直到那时+1 (5认同)
  • @drozdzynski我刚刚在mix.exs文件的`def application`部分的应用程序列表中添加了`:inets`。 (3认同)
  • 对我而言,它最终还是mix.exs应用程序依赖项中的:: ineets。 (2认同)