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?
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?
A :git
dependency perhaps. But local path dependencies or source control dependencies are your only chance when not (yet) released on hex.pm.
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.
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.
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
This is correct. I use path deps on pushex/examples/test_frontend_socket/mix.exs at master · pushex-project/pushex · GitHub 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.
I might note that if you want to completely replicate the environment as it would be with a hex package then the command mix hex.build -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.