Ebin folder and .app file


the question is the following: is ebin folder limited only to modules named in .app file, or user can (for whatever reason) manually add more .beam files to it (such that manually added files are not part of the application)? Is placing extra modules in ebin folder considered a bad practice? It can come up handy in some scenarios because you don’t need to add additional code path to load those extra modules.

The problem is, if I use application:load/1, extra modules are not loaded and are not part of the application I just loaded. However, when using xref:add_application to add application to xref server, it adds those extra modules and associates them to the applications (one can check by calling xref:info(<server_ref>, modules). modules entry in .app file is not even consulted.

Shouldn’t xref:add_application/2 and application:load/1 load the same modules? The solution is either to limit ebin folder only to modules named in .app file or to modify the behavior of xref (I could come up with PR).

Thanks to @kuna.prime who pointed-out this edge-case.


FWIW application:load/1 doesn’t load any modules. It just loads the .app file


That is true, lesson learned :smiley:
Anyway, maybe I missed the point here. The thing is, even though some compiled modules are in ebin folder they are not associated with the application when they are not listed in modules list in app file (which is correct behavior). The thing is, when xref “loads” application into it’s server, it associates those extra modules to the application, not even consulting .app file - it just scans all .beam files in the folder (we believe that this is wrong behavior).

1 Like