[Proposal] Hint `elixirc_paths` for "is not loaded and could not be found"?

45 views
Skip to first unread message

Nathan Long

unread,
May 9, 2018, 5:25:27 PM5/9/18
to elixir-lang-core
I just added a `test/support` directory and `test/support/data_case.ex` to my Mix application. When I tried to `use MyApp.DataCase`, I got a `CompileError` like `module MyApp.DataCase is not loaded and could not be found`.

This confused me for a moment, because I clearly had the right name. After a few minutes, I realized the problem: `test/support` was not part of my `elixirc_paths` in `Mix.exs`. I needed:

def project do
[
...
      elixirc_paths
: elixirc_paths(Mix.env()),
...
]
end

and

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths
(_), do: ["lib"]

I don't know if it's a common cause, but perhaps this error could be made friendlier with a hint like "current `elixirc_paths` are..."?

José Valim

unread,
May 9, 2018, 5:34:52 PM5/9/18
to elixir-l...@googlegroups.com
Hi Nathan!

The issue is that the compiler is just one of many ways where we can define modules in Elixir. Maybe you expected this module to be define in your test_helper and you have a type in the module name. The module could also have come from a dependency and you had a typo in its name when using it.

I think ultimately pointing towards elixirc_paths would be misleading.



José Valim
Founder and 
Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/4dcf2571-976e-4fb4-8fd4-58b8cc0508b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Long

unread,
May 10, 2018, 9:27:15 AM5/10/18
to elixir-lang-core
Good points. Could we have an error message that gives multiple possible fixes, as you do here? Or do you think that would be too much text?


On Wednesday, May 9, 2018 at 5:34:52 PM UTC-4, José Valim wrote:
Hi Nathan!

The issue is that the compiler is just one of many ways where we can define modules in Elixir. Maybe you expected this module to be define in your test_helper and you have a type in the module name. The module could also have come from a dependency and you had a typo in its name when using it.

I think ultimately pointing towards elixirc_paths would be misleading.



José Valim
Founder and 
Director of R&D

On Wed, May 9, 2018 at 11:25 PM, Nathan Long <h...@nathanmlong.com> wrote:
I just added a `test/support` directory and `test/support/data_case.ex` to my Mix application. When I tried to `use MyApp.DataCase`, I got a `CompileError` like `module MyApp.DataCase is not loaded and could not be found`.

This confused me for a moment, because I clearly had the right name. After a few minutes, I realized the problem: `test/support` was not part of my `elixirc_paths` in `Mix.exs`. I needed:

def project do
[
...
      elixirc_paths
: elixirc_paths(Mix.env()),
...
]
end

and

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths
(_), do: ["lib"]

I don't know if it's a common cause, but perhaps this error could be made friendlier with a hint like "current `elixirc_paths` are..."?

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

José Valim

unread,
May 10, 2018, 9:29:14 AM5/10/18
to elixir-l...@googlegroups.com
It would be too much text. Those were only examples of where a module could have come from. There are more.



José Valim
Founder and 
Director of R&D

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b9df1290-677c-48f9-8c3c-54192db82156%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages