[erlang-questions] Problem with code:priv_dir

Gunilla Arendt <>
Wed Feb 14 14:52:45 CET 2007


code:priv_dir(Name) does not search *the directories* in the code path
for a directory named Name. It searches *the list of names* which
constitute the code path, and if there is a directory in the code path
called "something/Name" it returns "something/Name/priv".

I agree the documentation could be more clear on this...

Regards,
Gunilla, Erlang/OTP team


Robert Baruch wrote:
> Hi all,
> 
> Here's my scenario, running R11B-2. In my home directory, I have the  
> following directories:
> 
> mytest-0.1/
> mytest-0.1/ebin/
> 
> Now, I fire up the erl shell and try to run code:priv_dir(mytest):
> 
> ekmac:~ ek$ erl
> Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0]  
> [hipe] [kernel-poll:false]
> 
> Eshell V5.5.2  (abort with ^G)
> 1> code:priv_dir(mytest).
> {error,bad_name}
> 2> code:get_path().
> [".",
> "/usr/local/lib/erlang/lib/kernel-2.11.2/ebin",
> "/usr/local/lib/erlang/lib/stdlib-1.14.2/ebin",
> "/usr/local/lib/erlang/lib/xmerl-1.0.5/ebin",
> (and so on)
> 
> Now, what I don't get is that the documentation for code:priv_dir/1  
> says:
> 
> "Searches the code path for a directory named .../Name[-Vsn][/ebin]  
> and returns the directory .../Name[-Vsn]/priv. It is not checked if  
> this directory really exists."
> 
> Code path contains "." ... check.
> ./mytest-0.1/ebin ... check.
> 
> So why isn't priv_dir/1 returning "./mytest-0.1/priv"?
> 
> Thanks for any help!
> 
> --Rob





More information about the erlang-questions mailing list