0

In a module I am calling HTTPoison.start() (related question Use HTTPoison to initialize a module attribute)

But I would like to configure it in mix.ex, I have read the mix ex documentation and added it to extra_applications: [:httpoison] but didnt work, also tried with applications and included_applications, what am I doing wrong?

Edit.

defmodule TestDep.MixProject do
  use Mix.Project

  def project do
    [
      app: :testdep,
      version: "0.1.0",
      elixir: "~> 1.6",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:httpoison, "~> 1.0"}
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
    ]
  end
end

defmodule TestDep do
  @moduledoc """
  Documentation for TestDep.
  """

  #HTTPoison.start()
  HTTPoison.get! "www.google.es"
end
lapinkoira
  • 8,320
  • 9
  • 51
  • 94
  • Posting a bare bones reproduction of your ```mix.exs``` file and the module where you are calling ```HTTPoison.start()```. Would help nail down the issue. For example, is httpoison included in ```defp deps()``` and has ```mix deps.get``` been run to download and install the application? – The Brofessor Jun 21 '18 at 13:13
  • I edited with a sample of code, is very easy to reproduce the issue, but I am afraid is not possible to be done without having to call HTTPoison.start() – lapinkoira Jun 21 '18 at 13:38
  • Adding :httpoison on extra_applications doesnt fix the issue, keeps crashing with compile error – lapinkoira Jun 21 '18 at 13:41
  • I'm able to copy the min example (uncommenting out ```HTTPoison.start()``` and get it to work great - what is the specific error you're encountering? Maybe that will point us in the right direction. – The Brofessor Jun 21 '18 at 23:44
  • I dont want to have that HTTPoison.start() but configure it instead in mix.ex in extra_applications for example – lapinkoira Jun 22 '18 at 06:27

1 Answers1

0

Until someone brings a possible solution I will answer a reply from elixir forums:

Applications listed in extra_applications are still started at start up time, not at compile-time. If you need to use HTTPoison at compile-time, you need to start it at compile time manually.

lapinkoira
  • 8,320
  • 9
  • 51
  • 94