[erlang-questions] bug in code:lib_dir

Joe Armstrong erlang@REDACTED
Tue Sep 18 10:14:53 CEST 2012

  > code:lib_dir(b)

Fails if the b sub-directory does not contain an ebin directory.
This means things like include_lib("b/include/foo.hrl") will fail
even though the file b/include/foo.hrl exists.

Suppose I have a directory structure like this:


a and b are Erlang applications - note that b has no ebin directory

Then I say

    > export ERL_LIBS=/home/joe/deps
    > erl


   > code:lib_dir(a).


   > code:lib_dir(b)

Now suppose a.erl contains the line


  I'll now get an error. The code server calls lib_dib(b) to resolve
the file name
reference. This fails and the system concludes (incorrectly) that
b/include/foo.hrl does not

  If I add an empty ebin directory to b then the error goes away.

  If you create src, ebin, include directories by hand you will never
see this error.

  But if you use rebar then the ebin directory is not created when you do
  > rebar create-app appid=<name>

  The ebin directory is created when you first run rebar compile.

  So recursive includes (a includes b/include and b includes
a/include) can possibly
  fail if no ebin directory is created.



More information about the erlang-questions mailing list