mix-test.watch icon indicating copy to clipboard operation
mix-test.watch copied to clipboard

Warning when configuring `:mix_test_watch` in Umbrella project

Open smt116 opened this issue 3 years ago • 0 comments

This is exactly the same issue as described in https://github.com/lpil/mix-test.watch/issues/28. However, moving the options under the dev configuration (via if statement or using dedicated config/dev.exs file) does not solve the problem when the package is added to the root mix.exs of the umbrella project.

Steps to reproduce

  1. Run mix new sample_umbrella --umbrella,

  2. Run cd sample_umbrella,

  3. Apply the following changes:

    diff --git a/config/config.exs b/config/config.exs
    index ab23e80..6690b3f 100644
    --- a/config/config.exs
    +++ b/config/config.exs
    @@ -16,3 +16,7 @@ import Config
     #       format: "$date $time [$level] $metadata$message\n",
     #       metadata: [:user_id]
     #
    +
    +if Mix.env == :dev do
    +  config :mix_test_watch, clear: true
    +end
    diff --git a/mix.exs b/mix.exs
    index 0d95de0..7dcb200 100644
    --- a/mix.exs
    +++ b/mix.exs
    @@ -16,6 +16,6 @@ defmodule SampleUmbrella.MixProject do
       #
       # Run "mix help deps" for examples and options.
       defp deps do
    -    []
    +    [{:mix_test_watch, "~> 1.0", only: :dev, runtime: false}]
       end
     end
    diff --git a/mix.lock b/mix.lock
    new file mode 100644
    index 0000000..3c731c5
    --- /dev/null
    +++ b/mix.lock
    @@ -0,0 +1,4 @@
    +%{
    +  "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
    +  "mix_test_watch": {:hex, :mix_test_watch, "1.0.2", "34900184cbbbc6b6ed616ed3a8ea9b791f9fd2088419352a6d3200525637f785", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "47ac558d8b06f684773972c6d04fcc15590abdb97aeb7666da19fcbfdc441a07"},
    +}
    
  4. Start the console: iex -S mix

  5. Notice the following output:

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

    You have configured application :mix_test_watch in your configuration file, but the application is not available.

    This usually means one of:

    1. You have not added the application as a dependency in a mix.exs file.

    2. You are configuring an application that does not really exist.

    Please ensure :mix_test_watch exists or remove the configuration.

    Interactive Elixir (1.11.3) - press Ctrl+C to exit (type h() ENTER for help) iex(1)>

Workaround

To suppress the warning, you need to add the dependency to one of the applications.

smt116 avatar Mar 09 '21 12:03 smt116