pikdum
Elixir 1.19 upgrade issues - compiler warnings + test failures
Hello,
I’m trying to upgrade a pretty large project from Elixir 1.18.4 to Elixir 1.19.1 (1321 modules), but seeing some compiler warnings saying modules aren’t available.
These show with both OTP 27 and OTP 28, so I’m guessing it’s related to Elixir 1.19 changes rather than OTP.
Erlang/OTP 28 [erts-16.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
warning: you are implementing a protocol for Foobar.Resources.User.V2.Api but said module is not available. Make sure the module name is correct. If Foobar.Resources.User.V2.Api is an optional dependency, please wrap the protocol implementation in a Code.ensure_loaded?(Foobar.Resources.User.V2.Api) check
│
43 │ defimpl Bamboo.Formatter, for: Foobar.Resources.User.V2.Api do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ lib/foobar/email/recipient.ex:43: (file)
warning: you are implementing a protocol for Foobar.Resources.Baz.V1.Api but said module is not available. Make sure the module name is correct. If Foobar.Resources.Baz.V1.Api is an optional dependency, please wrap the protocol implementation in a Code.ensure_loaded?(Foobar.Resources.Baz.V1.Api) check
│
49 │ defimpl FunWithFlags.Group, for: Foobar.Resources.Baz.V1.Api do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ lib/foobar/feature_flags/group.ex:49: (file)
The modules exist, so I’m not sure why defimpl is throwing warnings or why only these two, we have dozens more that look near identical that don’t.
We’re also seeing extra warnings when running tests, from some modules only compiled for tests, through elixirc_paths config like this:
defp elixirc_paths(:test), do: elixirc_paths(:dev) ++ ["test/support", "test/resources", "test/benchmarks"]
defp elixirc_paths(_), do: ["lib", "web"]
warning: invalid association `test_comment_test_categories` in schema Foobar.Test.Support.Framework.Resources.TestCategory.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestCategory.V1.JoinTables.TestCommentTestCategory does not have field `api_id`
└─ test/support/framework/resources/test_category/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestCategory.V1.Api (module)
warning: invalid association `test_editor_test_posts` in schema Foobar.Test.Support.Framework.Resources.TestPost.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestPost.V1.JoinTables.TestEditorTestPost does not have field `api_id`
└─ test/support/framework/resources/test_post/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestPost.V1.Api (module)
warning: invalid association `test_editor_test_posts` in schema Foobar.Test.Support.Framework.Resources.TestEditor.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestEditor.V1.JoinTables.TestEditorTestPost does not have field `api_id`
└─ test/support/framework/resources/test_editor/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestEditor.V1.Api (module)
warning: invalid association `test_comment_test_categories` in schema Foobar.Test.Support.Framework.Resources.TestComment.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestComment.V1.JoinTables.TestCommentTestCategory does not have field `api_id`
└─ test/support/framework/resources/test_comment/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestComment.V1.Api (module)
warning: invalid association `test_post_test_categories` in schema Foobar.Test.Support.Framework.Resources.TestPost.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestPost.V1.JoinTables.TestPostTestCategory does not have field `api_id`
└─ test/support/framework/resources/test_post/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestPost.V1.Api (module)
warning: invalid association `test_post_test_categories` in schema Foobar.Test.Support.Framework.Resources.TestCategory.V1.Api: associated schema Foobar.Test.Support.Framework.Resources.TestCategory.V1.JoinTables.TestPostTestCategory does not have field `api_id`
└─ test/support/framework/resources/test_category/v1/api.ex: Foobar.Test.Support.Framework.Resources.TestCategory.V1.Api (module)
These are for our internal framework tests and are causing over 100 test failures.
Everything compiled with no warnings with Elixir 1.18.4, and no test errors.
Our internal framework is pretty macro heavy, so maybe some behavior changed there?
All those JoinTables modules are dynamically created by our framework through macros, but only the test/support ones are failing.
If it was totally broken, I’d expect to see test failures or warnings for our actual application rather than only this framework code.
Not really sure where to start looking. Any ideas?
Thanks
Marked As Solved
josevalim
Don’t think they’d be the issue.
The reason I asked is because there was a bug related to Ash and dependencies which caused exceptions similar to yours, and a new version was published yesterday. ![]()
The unknown fields are are separate issue though. If you are defining fields programatically, depending if a module exists or not, then that would be the root cause. If either Ash or your framework use Code.ensure_compiled! more consistently (instead of just checking for it), you should have reliable compilation errors. The reason we can’t use Code.ensure_compiled! when checking for protocols is backwards compatibility.
Also Liked
pikdum
Thanks! I’ll poke around areas like that in our framework and see if I can get things working.
Update: Found a spot where we were creating a module inside of a macro, added a call to Code.ensure_compiled!/1 after that and seems to have fixed all the problems. ![]()







