[erlang-questions] Help on priv_dir please

Richard Carlsson carlsson.richard@REDACTED
Wed Jun 20 23:22:24 CEST 2018

First, if you run code:which(ModuleName) for any module of the app, it
should show you a path that ends in .../APPNAME[-VSN]/ebin/ModuleName.ebin
- if it doesn't, code:priv_dir(APPNAME) won't recognize the name as an app
and you'll get {error, bad_name}. For example: code:which(lists) ->
code:priv_dir(stdlib) -> ".../stdlib-3.4/priv". This should work even if
the priv directory doesn't in fact exist (stdlib does not have one).

Second, for ERL_LIBS to work, it should point out the directory above your
set of applications, as in ".../lib", not an ebin directory or a single app
directory. Directories under ERL_LIBS that contain an ebin subdirectory
will be recognized as apps, and their ebins will be added to the path.

Hope this helps.


2018-06-20 22:58 GMT+02:00 Bob Cowdery <bob@REDACTED>:

> This code:priv_dir/1 has me completely baffled. The code for gen_serial
> will only resolve the directory if I leave it in its original directory and
> add the ebin to the code path. If I move the files to my own tree it wont
> give me anything except {error, bad_name}. I've put in the correct
> directory structure according to the docs, added an Application.app file
> and tried various names in the call including ?MODULE, the file I am
> running and the app name. I also added the ebin path to ERL_LIBS to no
> avail.
> There is also some weird thing going on with the paths. Even if I remove
> the gen_serial original code path from .erlang and then build it from some
> random directory it still builds that one even though I have a copy in my
> tree and the code path only points there. Is there some cache somewhere?
> On 6/19/2018 8:40 PM, Vance Shipley wrote:
> Heh, I just posted about this in another thread. You probably have a
> problem related to your installed path. It's not enough to set the code
> path, you need to include the parent directory in the ERL_LIBS environment
> variable.
> On Tue, Jun 19, 2018, 01:52 Bob Cowdery <bob@REDACTED> wrote:
>> Hi,
>> I'm trying to get gen_serial up and running. I've tracked the problem
>> down to a line which boils down to code:priv_dir(gen_serial).
>> This is intending to get the port executable path but returns bad_name.
>> Why would this call fail?
>> Thanks
>> BobC
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180620/7dcbf56d/attachment.htm>

More information about the erlang-questions mailing list