From fc9b11afcadc1090f613eaef54873f17fc9020c5 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Thu, 29 Nov 2018 23:00:23 -0500 Subject: [PATCH] Clear app details cache before checking in paths The app data, when set by `rebar3_app_discover` basically does not include the modules if it was derived from the .app.src file, even if at a later point the modules were compiled. Since there is currently no clear way to add that information reliably across all compiler versions in all types of compilers, we simply clear the cache and re-derive the information when required. This might have a small performance cost, but is required for correctness whenever an application's first build is run. Specifically, this bug was detected when a plugin included lager's parse transform, and the application itself also required it, but two distinct versions were needed. This patch finalizes fixing this issue. --- src/rebar_paths.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rebar_paths.erl b/src/rebar_paths.erl index 82c02186..c49ed36d 100644 --- a/src/rebar_paths.erl +++ b/src/rebar_paths.erl @@ -111,7 +111,6 @@ purge_and_load([{_Group, Apps}|Rest], Seen) -> %% Shouldn't unload ourselves; rebar runs without ever %% being started and unloading breaks logging! AppName =/= <<"rebar">>], - %% 4) CandidateMods = lists:append( %% Start by asking the currently loaded app (if loaded) @@ -121,8 +120,10 @@ purge_and_load([{_Group, Apps}|Rest], Seen) -> Mods; undefined -> %% if not found, parse the app file on disk, in case - %% the app's modules are used without it being loaded - case rebar_app_info:app_details(App) of + %% the app's modules are used without it being loaded; + %% invalidate the cache in case we're proceeding during + %% compilation steps by setting the app details to `[]' + case rebar_app_info:app_details(rebar_app_info:app_details(App, [])) of [] -> []; Details -> proplists:get_value(modules, Details, []) end