Prevent a mix task from automatically running mix compile

I’m using a custom mix task to download a binary dependency we have. I also wish to use that binary dependency as part of a pre-compile hook elsewhere in our code. So I have a circular dependency: Running the mix task causes the rest of the app to get compiled… but the mix task hasn’t downloaded the binary dependency yet so compilation fails.

Is there a way I can prevent the mix task from running mix compile somehow?

Not sure if that would solve your problem but instead of using a mix task you could add a compiler step before the elixir compilation. And have that step download the binary if it is not already done. See mix compile — Mix v1.12.3

Or you could add the binary as a non-app dependency from a git repo so it is downloaded automatically with mix deps.get.

1 Like