I have an Elixir project managed by mix. When started with iex -S mix
all Elixir modules within my lib folder get loaded. An Erlang module in an .erl
file within the lib folder doesn't.
I'd like to know either a) how do I load an Erlang module explicitly from my Elixir code or b) what do I have to do to have mix autoload the Erlang module, too. (Preferably both ;) )
Erlang modules that get compiled will get included automatically. If your local erlang module is in the lib/
folder though the problem may be that its not getting compiled.
The mix task that handles compiling erlang modules ( mix compile.erlang ) assumes the default path where the erlang modules are included is in a src/
directory.
If you'd prefer to place it somewhere else, you can adjust the configuration via the :erlc_paths
parameter, in your project config in mix.exs
. A bare bones example would look like:
def project do
[
app: :test,
version: "0.1.0",
elixir: "~> 1.6",
erlc_paths: ["lib"],
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.