Skip to content

Mix fails to build Erlang application with locally defined and referenced behaviours #15100

@eseres

Description

@eseres

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.19.5 (compiled with Erlang/OTP 28)

Operating system

linux

Current behavior

If an Erlang application both defines and references behaviour modules, Mix will throw a warning like this:

0.522 apps/my_app/src/a_module.erl:2:2: behaviour my_behaviour undefined                                                                                        
0.522 %    2| -behaviour(my_behaviour).
0.522 %     |  ^
0.522 
0.620 compile: warnings being treated as errors

This is because Mix compiles the files in alphabetical order and a_module.erl comes before my_behaviour.erl.

We have been using rebar3 for a long time without this issue. We are trying to switch to Mix and can't seem to get around this problem.

Are we missing something or is this really a limitation? If it is a limitation, could it be addressed in a future Mix version?

Expected behavior

The expectation is that regardless of the relative alphabetical order between the behaviour module and the module referencing it, the application should be able to be successfully compiled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions