What is best way to catch module duplication caused by multiple protocol implementations?

We have a large umbrella application where we updated a dependency and the release failed due to duplicated module warnings we didn’t see until it was too late.

mix distillery.release --app andi --env=prod
...
==> Release failed, during .boot generation:
        Duplicated modules: 
    	'Elixir.Brook.Serializer.Protocol.MapSet' specified in andi and brook_serializer
    	'Elixir.Brook.Deserializer.Protocol.MapSet' specified in andi and brook_serializer

Is there a way to check specifically for duplicated protocol implementations using mix, and without incurring the time cost of running a mix distillery.release? We have several other warnings for code generated by other libraries (macros from retry for example) we don’t control that make using --warning-as-errors unviable.

Here is something we taped together to catch it, but we’re interested in any better ideas.

Mix.Tasks.Compile.Elixir.run(["--force"]) 
|> elem(1) 
|> Enum.filter(fn warning -> 
    warning
    |> inspect() # this is always a good idea
    |> String.downcase() 
    |> String.contains?("redefining module")
end)
1 Like

As far as I remember warnings as errors will do nothing on compiling the deps.

Aside of that, do a clean and rebuild, there you should see those warnings as well.

1 Like