3

I created a project like this:

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

The structure looks like this:

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

Now I want to include foo.hrl in barlib.erl:

-module(barlib).

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


foo()->
    ok.

compiling gives:

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

When I remove the -include_lib directive and call rebar3 shell I can retrieve code:lib_dir(foo) and code:lib_dir(bar)

This looks good to me:

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

So, why does include_lib not work?

TIA

murphy
  • 524
  • 4
  • 16

1 Answers1

6

does app bar depend on app foo in its application tuple in its .app file? That is usually required to make things work.

I GIVE TERRIBLE ADVICE
  • 9,578
  • 2
  • 32
  • 40