【问题标题】:Why does rebar use my erl_opts to compile my deps?为什么 rebar 使用我的 erl_opts 来编译我的 deps?
【发布时间】:2013-12-26 06:48:28
【问题描述】:

我的结构类似于以下:

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

我的顶级rebar.config 文件如下所示:

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

A/rebar.config 如下所示:

{deps, [
    %% deps
    ]}.

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

现在,我的一个依赖项没有为其所有函数提供-spec,因此warnings_as_errors 导致编译失败。

我原以为 erl_opts 只会影响我的代码,并且依赖项有自己的选项。为什么rebar 会这样做?

【问题讨论】:

  • 您是否尝试过从配置文件中删除lib_dirs?我认为deps是默认的依赖目录,你可能不需要指定为lib_dir
  • 无法在 R15B03 上使用 rebar 2.1.0-pre 重现它(使用相同的配置)。你运行的是什么版本?

标签: erlang rebar


【解决方案1】:

事实证明,我的一个依赖项没有rebar.config,因此 rebar 正在使用我的选项对其进行编译。

令人困惑的是erl_opts 不是设置在顶级rebar.config 中,而是设置在本地rebar.config 文件中。这是具有deps 子句的文件。

在这种情况下,选项似乎是“横向”继承的。

【讨论】:

    【解决方案2】:

    我无法使用以下版本的钢筋重现此问题:

    rebar 2.1.0-pre R15B03 20131210_073701 git 2.1.0-pre
    

    在我的本地设置中,使用相同的配置(goldrush 是我的依赖项):

    ...
    ==> 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]
    ...
    

    如您所见,这两个应用程序接收到两组不同的选项。

    能否启用调试并发布相关输出?

    ./rebar -vvv clean compile
    

    你运行的是什么版本的 rebar/Erlang?

    【讨论】:

      猜你喜欢
      • 2015-11-30
      • 2015-08-16
      • 1970-01-01
      • 2011-08-27
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      • 2018-12-12
      • 2016-02-18
      相关资源
      最近更新 更多