Protocol not working when used as a dependency

I’m learning Liveview following Bruce Tate course. I’ve implemented this protocol following along the course. And it works:

location: {40, 0}
refection: false
rotation: 0

But as soon as I started using this package as dep for this other app, it stopped working:

  message: "got Protocol.UndefinedError with message \"protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream\" while inspecting %{__struct__: Tetris.Brick, location: {40, 0}, name: :i, reflection: false, rotation: 0}"

I’ve read online that for some people Protocol failures where common when working in Umbrella projects, but my case is not really an umbrella app.

Any help you can give me is appreciated.

Please share your implementacion of the protocol. Somewhere inside you seem to have not initialized something that makes an attempt to enumerate nil.

The issue has nothing to do with your protocol, it is working fine.


Judging by the code in Tetris, it relies on the :shapes config option to work properly. Since you don’t have it set up, you are getting a nil in the Tetris.Block.shape/1 function, which is why the implementation of Inspect crashes.

1 Like

Thanks @aenglisc that was it, I made my code non reliant on the :shapes option in the config.exs .
My guess is that when I imported the package as a dep, it was switching the the config file for the consumer’s (?)