-include_lib 找不到我的图书馆

-include_lib doesn't find my library

我创建了一个这样的项目:

$> rebar3 new release foo
$> cd foo
$> rebar3 new app bar

结构如下所示:

$> tree foo

|-- _build
|   `-- default
|-- _checkouts
|   |-- bar -> ../bar
|   `-- rebar.lock
|-- apps
|   `-- foo
|       |-- include
|       |   `-- foo.hrl
|       `-- src
|           |-- foo.app.src
|           |-- foo_app.erl
|           `-- foo_sup.erl
|
|-- bar
|   `-- src
|       |-- bar.app.src
|       |-- bar_app.erl
|       |-- bar_sup.erl
|       `-- barlib.erl
|-- config
|   |-- sys.config
|   `-- vm.args
|-- rebar.config
`-- rebar.lock

现在我想在 barlib.erl 中包含 foo.hrl:

-module(barlib).

%% API
-export([foo/0]).
-include_lib("foo/include/foo.hrl").


foo()->
    ok.

编译给出:

$> rebar3 compile
===> Verifying dependencies...
===> Compiling bar
===> Compiling _checkouts/bar/src/barlib.erl failed
_checkouts/bar/src/barlib.erl:5: can't find include lib "foo/include/foo.hrl"

当我删除 -include_lib 指令并调用 rebar3 shell 时,我可以检索 code:lib_dir(foo)code:lib_dir(bar)

这对我来说不错:

$> rebar3 shell
===> Verifying dependencies...
===> Compiling bar
===> Compiling foo
Eshell V9.3  (abort with ^G)
1> ===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases (http://www.rebar3.org/docs/releases)
1> ===> Booted bar
1> ===> Booted foo
1> ===> Booted sasl
1> 
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.139.0>},
                       {id,alarm_handler},
                       {mfargs,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]
1> 1> 
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.138.0>},
                       {id,sasl_safe_sup},
                       {mfargs,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]
1> 1> 
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.140.0>},
                       {id,release_handler},
                       {mfargs,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]
1> 1> 
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
         application: sasl
          started_at: nonode@nohost
2> code:lib_dir(foo).
"/usr/home/xxxx/foo/_build/default/lib/foo"
3> code:lib_dir(bar).
"/usr/home/xxxx/foo/_checkouts/bar"
4> 

那么,为什么 include_lib 不起作用?

TIA

应用程序 bar 是否依赖于应用程序 foo 在其 .app 文件中的 application 元组?这通常是使事情正常工作所必需的。