Floki.text/1 defined in application :floki is used by the current application but the current application does not depend on :floki

Hi,

I am using a dependency (in this case floki, but it happens with tesla and jason as well) in one of my projects. But the Elixir compiler keeps giving me this warning:

warning: Floki.text/1 defined in application :floki is used by the current application but the current application does not depend on :floki. To fix this, you must do one of:

  1. If :floki is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :floki is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :floki, you may optionally skip this warning by adding [xref: [exclude: [Floki]]] to your "def project" in mix.exs

I don’t really understand the problem, I already defined floki as a dependency:

  defp deps do
    [
      {:floki, "~> 0.7"},
      {:tesla, "~> 1.3.0", optional: true},
      {:ex_doc, ">= 0.0.0", only: :dev},
      {:jason, "~> 1.2", only: [:dev, :test]}
    ]
  end

I am using Elixir 1.11.3:

Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [dtrace]

Elixir 1.11.3 (compiled with Erlang/OTP 23)

Am I doing something wrong? The project in question is located here: GitHub - ckruse/microformats2-elixir: Microformats2 parser in Elixir

Best regards,
Christian Kruse

I believe this is the part you will need to apply in your mix.exs. Add :floki to :extra_applicatoins.

I successfully use floki in a project of mine, where I only define it in the deps.

defp deps do
    [
      {:phoenix, "~> 1.5.7"},
      {:phoenix_ecto, "~> 4.1"},
      {:ecto_sql, "~> 3.4"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_live_dashboard, "~> 0.4"},
      {:telemetry_metrics, "~> 0.4"},
      {:telemetry_poller, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:httpoison, "~> 1.7"},
      {:floki, "~> 0.29.0"}
    ]
  end

Is it maybe the different version that matters?

Or, is the order of the deps that matter?

What is your application/0 content?

@cjk if you are using :applications in application/0 then you need to list all dependant applications there. Replace that key with :extra_applications and the message will be gone.

1 Like
 def application do
    [
      mod: {MyApp.Application, []},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

The mix.exs in that project still uses :applications key, which makes mix’ dependency inference not work.

I have created a PR that should fix the issue.

4 Likes

Thank you very much! This indeed fixes the problem. Much appreciated!

:floki is not part of Erlang, nor Elixir.