Developing libraries - is it possible to try in a mock app before publishing to hex?


I’m starting to develop a hex package, but I would really like to try it out in a mock app before publishing it to hex. Is that possible?

I’ve set it as a local dependency in mix.exs, which works, but not very smoothly. Is there a better way?

1 Like

A :git dependency perhaps. But local path dependencies or source control dependencies are your only chance when not (yet) released on

1 Like

Meaning exactly what? I never experienced any issue with {path: "../my_lib"} mix dependency config.


@aaron-price is probably talking about the fact that code changes in the library aren’t picked up instantly in the mock application.

1 Like

With a path dependency any changes should be picked up just fine.


Then I’m perhaps misremembering things. I thought they were copied over to deps and not automatically rebuilt…

They are surely rebuilt semi-automatically with mix deps.compile. I usually use a mix alias

compile: ["deps.compile my_dep", "compile"]

But probably even that is not needed.

1 Like

Path deps aren’t copied over to the parent app so changes in the dep should be picked up immediately by the compiler. That has been my experience; I use this approach a lot.


Sorry, yes, I am referring to the fact that changes aren’t picked up right away.

Just tried deps.compile, that worked! Thanks :smiley:

This is correct. I use path deps on and it works out pretty nicely.

One thing that is neat about running an example app in the same repo as the library is that you can set it up in your CI test runner. The usefulness of this really depends on the particular project.

1 Like

I might note that if you want to completely replicate the environment as it would be with a hex package then the command mix -o ../host_app/deps/dep_name —unpack will build the package and unpack it as a dep in your host application. Then you can leave your mix.exs deps as is and still test with a local branch.