Background
I have an application :myapp
and I am trying to add some web functionality to it from zero using Plug
. However, even though I have all the files and modules, present, I still can’t launch it because iex can’t find the modules that are outside the lib folder.
Error
When running iex -S mix
I get the following error:
** (Mix) Could not start application myapp: exited in: MyApp.start(:normal, [])
** (EXIT) an exception was raised:
** (UndefinedFunctionError) function MyApp.Web.MetricsExporter.setup/0 is undefined (module MyApp.Web.MetricsExporter is not available)
MyApp.Web.MetricsExporter.setup()
(myapp) lib/application.ex:19: MyApp.start/2
(kernel) application_master.erl:277: :application_master.start_it_old/4
Code
To fix the above error, I added the following lines to my mix.exs
:
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
However the error still persists. My folder structure is the following:
config
lib
|_ application.ex
web
|_MetricsExporter.ex
Question
Why can’t iex find and compile the MetricsExporter file?