# Ebin folder and .app file

**URL:** <https://erlangforums.com/t/ebin-folder-and-app-file/2503>\
**Category:** Proposals: Ideas\
**Tags:** erlang, erlang-otp, xref\
**Created:** [March 28, 2023, 3:19pm UTC](https://erlangforums.com/t/ebin-folder-and-app-file/2503 "2023-03-28T15:19:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmin](https://erlangforums.com/user_avatar/erlangforums.com/mmin/32/2193_2.png) [@mmin](https://erlangforums.com/u/mmin)\
**Post date:** [March 28, 2023, 3:19pm UTC](https://erlangforums.com/t/ebin-folder-and-app-file/2503/1 "2023-03-28T15:19:33Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![michalmuskala](https://erlangforums.com/user_avatar/erlangforums.com/michalmuskala/32/247_2.png) [@michalmuskala](https://erlangforums.com/u/michalmuskala)\
**Post date:** [March 30, 2023, 8:33am UTC](https://erlangforums.com/t/ebin-folder-and-app-file/2503/2 "2023-03-30T08:33:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmin](https://erlangforums.com/user_avatar/erlangforums.com/mmin/32/2193_2.png) [@mmin](https://erlangforums.com/u/mmin)\
**Post date:** [March 30, 2023, 12:33pm UTC](https://erlangforums.com/t/ebin-folder-and-app-file/2503/3 "2023-03-30T12:33:32Z")

</div>

That is true, lesson learned 😃  
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).
