pikdum

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

josevalim

Creator of Elixir

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. :slight_smile:

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

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. :slight_smile:

Where Next?

Popular in Troubleshooting Top

alexlanderzander
Hello everyone, I’m working on a blockchain project in Elixir and I’m implementing some of the core cryptography in a Rust NIF using Rus...
New
tomekowal
Hi! I am trying to pinpoint why my project has issue on incremental compilation when running tests in elixir 1.19.0-rc.0-otp-26 I am ru...
New
chocolatedonut
Besides (over)logging every code-path leading to Repo.insert_all, is it possible to make Postgrex and/or ecto_sql log the exact, failing ...
New
Ferenc
I have installed it on Phoenix 1.8.1 (without authentication or other packages and got 2 problems). I had to set up things manually the ...
New
mooreryan
In a project I’m working on, I cannot get tests with breakpoints or pry working. Here is an example in a new mix project. Create a fresh...
New
wktdev
I tried to learn Elixir a few years ago and stopped. I am trying again. In the code below I have a GenServer that is started by a Superv...
New
onelastdance
Hey there, Using the install script method recommended here on Ubuntu 24.04: And then running the following commands: iex> :obser...
New
klo
Is there any way to go from a float 1.0 to 1.00 while retaining the float() type?
New
rayex
Hi, I am using the following versions: Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] El...
New
apoorv-2204
The Issue of Enums in Elixir Elixir doesn’t have a native enum construct, so we usually rely on atoms, strings, or macros to represent na...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement