Background
I have created an OTP compliant application called :my_app
and I have it in a GitHub repository. I want to use this application as a dependency in a :mother_app
but I am failing to even compile the code.
Code
Here is how I am importing :my_app
into :mother_app
:
defmodule MotherApp.Mixfile do
use Mix.Project
def project do
[
app: :mother_app,
version: 0.1.0,
elixir: "~> 1.8",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix] ++ Mix.compilers(),
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
def application do
[
mod: {MotherApp, []},
extra_applications: [:my_app]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
defp deps do
[
{:phoenix, "~> 1.4" },
{:phoenix_html, "~> 2.0" },
{:my_app, git: "git@github.com:cool_username/my_app", tag: "0.1.1" }
]
end
end
Looks like an ordinary simple file, nothing new here. I use MyApp
in a file called dispatcher.ex that looks something like this:
defmodule MotherApp.Dispatcher do
require MyApp
def work(args) do
MyApp.InnerModule.work()
end
end
Problem
However, when I run mix compile
I get the following error:
== Compilation error in file lib/mother_app/dispatcher.ex ==
** (CompileError) lib/mother_app/dispatcher.ex:15: module MyApp is not loaded and could not be found
And mix.exs shows me this cryptic error as well:
an exception was raised:
** (ArgumentError) argument error
(stdlib) eval_bits.erl:101: :eval_bits.eval_exp_field1/6
(stdlib) eval_bits.erl:92: :eval_bits.eval_field/3
(stdlib) eval_bits.erl:68: :eval_bits.expr_grp/4
(stdlib) erl_eval.erl:484: :erl_eval.expr/5
(stdlib) erl_eval.erl:888: :erl_eval.expr_list/6
(stdlib) erl_eval.erl:240: :erl_eval.expr/5
(stdlib) erl_eval.erl:232: :erl_eval.expr/5
(elixir) src/elixir.erl:258: :elixir.eval_forms/4(undefined)
What am I doing wrong?