bug/feature in code_server.erl

Martin Bjorklund mbj@REDACTED
Thu Feb 9 13:05:29 CET 2006


Hi,

code:del_path() doesn't behave as expected:

nassa src> ls /home/mbj/src/a.beam 
/home/mbj/src/a.beam

nassa src> erl -pa /home/mbj/src 
Erlang (BEAM) emulator version 5.4.10 [source] [hipe]

Eshell V5.4.10  (abort with ^G)
1> code:get_path().
["/home/mbj/src",
 ".",
 "/home/mbj/src/otp_src_R10B-8/installed/lib/erlang/lib/kernel-2.10.11/ebin",
  <OTP dirs removed>

2> code:del_path("/home/mbj/src").
true
3> code:which(a).
non_existing
4> code:load_file(a).
{module,a}
5> code:which(a).    
"/home/mbj/src/a.beam"

6> code:get_path().
[".",
 "/home/mbj/src/otp_src_R10B-8/installed/lib/erlang/lib/kernel-2.10.11/ebin",
  <OTP dirs removed>



In 1. we see that /home/mbj/src is in the path
In 2. /home/mbj/src is deleted
In 3. we can see that a.beam is not found in the path
In 4. we can still load a.beam, from /home/mbj/src, although
/home/mbj/src is not in the path.


[browsing code_server.erl...]

The problem is in code_server:mod_to_bin's last clause:

mod_to_bin([], Mod) ->
    %% At last, try also erl_prim_loader's own method
    File = code_aux:to_path(Mod) ++ code_aux:objfile_extension(),
    case erl_prim_loader:get_file(File) of

And it turns out that /home/mbj/src is in erl_prim_loader's path,
since it was added with -pa.

But why is this clause here?  code_server grabs the path from
erl_prim_loader at startup, and after that code should be loaded
according to the path in code_server.

The workaround for me is to clear erl_prim_loader's path.



/martin




More information about the erlang-questions mailing list