简体   繁体   中英

Undefined function warnings during umbrella compilation

I have encountered a strange issue within my umbrella application structure. When I'm compiling whole project after running mix clean command, I'm getting following warning message from application_a:

function ApplicationB.ModuleName.function_name/0 is undefined (module 
ApplicationB.ModuleName is not available)
  lib/file_name.ex:13`

The thing is that the module is there, ApplicationB.ModuleName.function_name/0 is defined and it's public. When I'm running the project from umbrella level in the interactive shell, everything works fine, I can call the function manually and it works as expected. I've been trying to do the research and as far as I can see the function of ApplicationB should be available for ApplicationA as both are within the same umbrella and there is no need to add them into deps list. If the function is defined in my /lib folder of application_b, it should be available to the rest of applications.

Does anyone have an idea how to get rid of the warning, and what is more important - explain it? :)

I believe you have macros from A used in B and vice versa. Elixir compiler builds the modules in the order, required to expand all macros to real AST. Within one application, cross-dependencies might even break the build.

But when two applications have cross-dependencies, Elixir compiler makes an assumption that the function might become available after the dependencies are met and everything is built and the error has downgraded to a warning.

To get rid of this warning, if you are absolutely positive there is indeed such a function defined, use Kernel.apply/3 instead of an explicit call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM