2

I have created an .erlang file to specify my working directory and to load certain modules at startup. I used the answer from here and it worked well when all the modules to be loaded resided in the current working directory:

shell_default:cd("C:/Users/Some/Default/Working Directory/ebin").
LP = fun() ->
        [code:ensure_loaded(list_to_atom(filename:rootname(filename:basename(F))))
         || P <- code:get_path(), F <- filelib:wildcard(P ++ "/*.beam")] 
     end.
spawn(LP).

When I try to load modules from other directories, I ran into some trouble. I changed the .erlang file:

shell_default:cd("C:/Users/Some/Default/Working Directory/ebin").
code:add_patha("C:/Users/Some/Other/File Location/ebin").
LP = fun() ->
        [code:ensure_loaded(list_to_atom(filename:rootname(filename:basename(F))))
         || P <- code:get_path(), F <- filelib:wildcard(P ++ "/*.beam")]
     end.
spawn(LP).

For some reason, the modules from the added code path are not loaded (I checked that the path is indeed added to the code path). When I tested filelib:wildcard(code:get_path() ++ "/*.beam") separately with the desired code path, I saw that it returns an empty string (i.e. it does not seem to find the .beam files in the added code path).

Any ideas of how to solve this problem? Thanks!

Community
  • 1
  • 1

0 Answers0