erlang - -include_lib 找不到我的库

标签 erlang rebar3

我创建了这样一个项目:

$> 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)代码: lib_dir(栏)

这对我来说很好:

$> 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

最佳答案

app bar 是否依赖于其 .app 文件中 application 元组中的 app foo?这通常是使事情正常运行所必需的。

关于erlang - -include_lib 找不到我的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51546948/

相关文章:

erlang - 如何不对 Rebar3 eunit 测试进行符号链接(symbolic link) priv 目录?

Erlang:supervisor(3),添加子进程

erlang - Mnesia - 指定存储策略时因 bad_type 中止

erlang - 如何将新的 Erlang 应用程序添加到 Rebar3 伞式项目?

elixir - 如何使用 Erlang/OTP 25 编译器重新编译 rebar3?运行 Elixir 1.13.4

Erlang 简单版本与牛仔 2.0.0 不起作用

erlang - Erlang 使用哪个 TCP 端口连接到远程节点?

erlang - Mnesia聚类

erlang - 如何获取给定句子中与特定模式匹配的特定单词列表?