5

I'm trying to create a release for my phoenix-framework project.

Everything is working fine, until my code need to do a specific action using :httpc module from OTP.

Apparently exrm, hasn't bundled the httpc module, and therefore could not find it.

I have tried to add it into my mix.exs application dependance, but as soon as I do, it will refuse to create a release due to an "error"

does anyone know how to fix this ?

For mix.env with :httpc as dependency :

$ 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."

For mix.env without :httpc dependency :

** (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
TheSquad
  • 7,385
  • 8
  • 40
  • 79
  • 3
    This could happen if the `inets` application wasn't added to the release. You can view the release's `script` file to see which applications are being started with the release. – Greg May 20 '16 at 10:38

1 Answers1

11

You may be missing the erlang-inets package. Try to install it or reinstall it again. If you are using Ubuntu you may install it with:

sudo apt-get install erlang-inets

Alternatively you may want to try adding the module :inets to your mix.exs application dependencies.

Sasha Fonseca
  • 2,257
  • 23
  • 41
  • 5
    The inets package is installed and working fine when using mix phoenix.server... however your post pointed me to the solution, adding the module :inets into my mix.exs application's depencies... Edit your solution and I'll mark it as accepted ;-) until then +1 – TheSquad May 19 '16 at 14:36
  • 2
    It ended up being `:inets` in mix.exs application dependencies for me also. – smitt04 Jun 19 '17 at 15:21
  • @thequad @smitt04 how you add ```:inets``` to mix.ex? – drozdzynski Dec 08 '17 at 14:11
  • 3
    @drozdzynski I just added `:inets` to the applications list in the `def application` portion of the mix.exs file. – smitt04 Dec 13 '17 at 16:36