Writing a lib, help me understand macros and deps conflicts

I am writing a library to be used in other elixir apps.
Suppose I have a module that needs to use something from another lib. In my example I am using Keathley’s Norm

defmodule MyLib.Something do
  use Norm

Well in tests everything looks fine, but when I try to use my library from a demo app, I get an error:

error: module Norm is not loaded and could not be found

Ok fair enough. But how am I supposed to do it?
Even if I install norm on both the app and the library, I get that error. Could you please explain to me on a conceptual level why that would be?

Can you explain what specifically you mean by “install” here?

Typically I’d expect mylib to declare a dependency on norm, so adding mylib to the application should install it as well.

1 Like

I think this resource will help you:

It provides an explanation for aliasing, requiring, imports etc.

1 Like

Ya that was my thinking as well! But apparently not…

By install, I mean going to mylib’s mix.ex, adding norm to the deps, running mix deps.get
It works fine in isolation, whether running tests in mylib, or opening IEX in mylib. So I know it does exist.

However, as soon as I depend on mylib from some phoenix application, and try to compile the phoenix app, it says norm doesn’t exist.

Even if I then add norm to the phoenix app AND to mylib. Still doesn’t exist. I am baffled. :face_with_raised_eyebrow:

Figured it out. I was running mix deps.compile but it needed the --force flag. Not positive why. Don’t even care.