Preventing rebar3 full recompile

Is there a surefire way to pin down what triggers a full rebar3 recompile? On an earlier version of Erlang24 running rebar3 shell did not recompile every file, upgrading to Erlang seems to have changed this behavior. The build is relatively complex, with ports, nifs, compile-time defined macros, .yrl and .xrl files, a fairly dynamic rebar.config.script, etc. Setting DEBUG=1 env var when running the shell command doesn’t seem to print anything that would stand out. This recompile behavior happens for running eunit and ct as well.

1 Like

A bit of clarification, rebar3’s version didn’t change, at 3.15.2 and no changes were made to any of the build configurations (rebar.config, rebar.config.script, Makefiles, etc)

Well downgrading back down to 24.0.2 seems to still trigger the full recompile. So it might not be specific to rebar3 but still confusing. General tips would still be welcome!

I’ve also now tried to upgrade to the newest rebar3, no dice there either.

I have no explanation for this, but in the root of my project there existed an ebin directory holding onto old .beam files, last modified a few days ago. It would appear removing that directory has solved the recompilation. For anyone who was interested in the full debugging, I bootstrapped rebar3 and added printing statements for the three conditions .erl files needed to be re-compiled, and their values. One condition was if the .erl files were newer than the .beam files, and logged that the .beams were several days out-of-date. Then I scoured the directory for files changed at the date and stumbled upon the top level ebin/ directory. Removing that solved the recompliling issue.


Yep. Rebar3 supports apps with prebuilt binaries and app files, which means we take whatever is in a top level ebin/ directory and copy it fresh into _build every run. So a top level ebin/ with stale files will make it seem to the code like the source file has changed since the last rebuild and trigger a recompile.

This is one of the oldest features and I got caught by it today myself.


Thank you for the explanation!

1 Like