Why does rebar use my erl_opts to compile my deps?

2k views Asked by At

I have a structure similar to the following:

rebar.config
deps/
apps/A/rebar.config

My top-level rebar.config file looks like the following:

{sub_dirs, ["apps/A"]}.
{lib_dirs, ["deps"]}.

A/rebar.config looks like the following:

{deps, [
    %% deps
    ]}.

{erl_opts, [debug_info, warn_missing_spec, warnings_as_errors]}.

Now, one of my dependencies doesn't provide -spec for all of its functions, so the warnings_as_errors causes the compile to fail.

I was expecting the erl_opts to only affect my code, and for the dependencies to have their own options. Why does rebar do this?

2

There are 2 answers

0
Roberto Aloi On

I cannot reproduce this using the following version of rebar:

rebar 2.1.0-pre R15B03 20131210_073701 git 2.1.0-pre

On my local setup, using your same config (goldrush is my dependency):

...
==> goldrush (compile)
DEBUG: Matched required ERTS version: 5.9.3.1 -> .*
DEBUG: Matched required OTP release: R15B03 -> .*
DEBUG: Min OTP version unconfigured
DEBUG: erl_opts [debug_info,warn_export_all]
...
==> myapp (compile)
DEBUG: Matched required ERTS version: 5.9.3.1 -> .*
DEBUG: Matched required OTP release: R15B03 -> .*
DEBUG: Min OTP version unconfigured
DEBUG: erl_opts [debug_info,debug_info,warn_missing_spec,warnings_as_errors]
...

As you can see, the two applications receive two different sets of options.

Could you enable debugging and post the relevant output?

./rebar -vvv clean compile

What version of rebar/Erlang are you running?

0
Roger Lipscombe On

It turns out that one of my dependencies doesn't have a rebar.config, so rebar is compiling it using my options.

What's confusing is that erl_opts is not set in the top-level rebar.config, but in a local rebar.config file. This is the file that has the deps clause.

It seems that the options are inherited "sideways" in this case.