I’m having a bit of an intermittent issue with a protocol with an Any implementation and a struct inheriting from that protocol and I’m not sure how to debug the issue or even reproduce consistently enough to file a bug so I thought I’d ask for suggestions here first.
I have a complex project with a couple protocols where this occurs. Unfortunately this project isn’t open source yet but hopefully soon. I was creating a textbook Any protocol to derive from similar to Protocols — Elixir v1.19.5 .
At first this bug arose when I stuck a dbg() statement into the Any implementation. When I did this and tried to derive the protocol I’d get something similar to:
== Compilation error in file lib/kerilixir/KERI/events/receipt_event.ex ==
\*\* (ArgumentError) could not load module Said.Saidifiable due to reason :nofile, cannot derive Said.Saidifiable for Kerilixir.Keri.ReceiptEvent
(elixir 1.19.5) lib/protocol.ex:331: Protocol.assert_protocol!/2
(elixir 1.19.5) lib/protocol.ex:1104: Protocol.derive/4
(stdlib 7.2) lists.erl:2641: :lists.foreach_1/2
(elixir 1.19.5) lib/protocol.ex:1097: Protocol.**derive**/3
lib/kerilixir/KERI/events/receipt_event.ex:22: (module)
When I removed the dbg() statement, removed the @derive, recompiled, added back the derive (without the dbg statement) the protocol would derive successfully. Adding the debug statement back would reproduce the error consistently.
Then somehow yesterday in fooling around with it I got the compilation and tests to pass with dbg() statement allowing me to troubleshoot the function call. Now when trying to derive other structs I’m getting this error consistently again. At this point, I don’t have the dbg() calls anymore in the Any implementation.
It seems like this is an issue in consolidation or compilation or something else that I don’t understand and so I’m reaching out for any ideas or even places to look in beginning to debug this. Its very frustrating because I’d just like to derive my implementation for most test cases and have a few exceptions with custom implementations but so far that has eluded me.
It does seem to happen more with mix test than mix compile if that changes things up. Then again, now its just occurring over and over with mix compile.
I tried to create a simpler example of the file structure and test structure I’m running here (tests fail but not the :nofile error) but failed to reproduce my error in this simpler example. GitHub - daidoji/simple_example
tl;dr something weird is happening in consolidation or compilation process and my protocol isn’t getting derived even though it should. Looking for ideas on how to troubleshoot as its intermittent and annoying.
Update: Running mix clean and then mix compile again gives a different struct whence this :nofile error appears. Removing the @derive from that particular module causes the rest of the modules to derive it successfully.






















