[erlang-bugs] bug in code:lib_dir

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


  > code:lib_dir(b)
   {error,bad_name}

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:

     /home/joe/deps/a/src
                     /include
                     /ebin
                   /b/src
                     /include/foo.hrl


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

Then I say

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

Then

   > code:lib_dir(a).
   "/home/joe/deps/a/"

But

   > code:lib_dir(b)
   {error,bad_name}

Now suppose a.erl contains the line

  -include_lib("b/include/foo.hrl")

  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
exist.

  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.

Cheers

/Joe



More information about the erlang-bugs mailing list