[erlang-questions] Specifying directories that contain .beam files

Joe Armstrong erlang@REDACTED
Thu Oct 25 22:02:08 CEST 2012


ERL_LIBS will not work. It will only find the beam files if the
directories under
ERL_LIBS follow a "regular" OTP /src/ebin etc structures

Since a beam file could in principle be in *any* directory this won't work.

The code path is set by editing a file ${HOME}/.erlang or
<directory where you started erlang>/.erlang

My ${HOME}.erlang looks like this:

code:add_patha("/Users/joe/code/jalib/work/beam").
code:add_patha("/Users/joe/Desktop/work/2007/jaerlang/socket_dist").
code:add_patha("/Users/joe/code/jalib/jalib-0.1/ebin").
code:add_patha("/Users/joe/code/jalib/jalib-0.1/src").
code:add_patha("/Users/joe/code/jaerlang_code").
...

%% Set paths to fix all rebar imports
Home = os:getenv("HOME").
Dir = Home ++ "/nobackup/erlang_imports/deps",
case file:list_dir(Dir) of
     {ok, L} ->
         lists:foreach(fun(I) ->
			       Path = Dir ++ "/" ++ I ++ "/ebin",
			       code:add_path(Path)
		       end, L);
    _ ->
	void
end.

The last part sets up the paths to find all rebar dependencies that I
have installed

code:add_path("....") adds ... to the code search path add_patha adds
to the beginning of the path

.erlang just contains a list of expressions which are evaluated when the system
starts.

You could read an evironment variable with os:getenv("VarName") and
set the paths
yourself.

ie in .erlang do this:


   L = string:tokens(os:getenv("MYENV", ":").
   [code:add_patha(I) || I<- L]

Then set your own envirnment variable

 export MYENV="/a/b/c:/d/e/f:...";

and "roll your own classpath" :-)

Cheers

/Joe











On Wed, Oct 24, 2012 at 6:12 PM, David Mercer <dmercer@REDACTED> wrote:
> On Wednesday, October 24, 2012, Yash Ganthe wrote:
>
>> Is it possible to setup an environment variable that lists all the
>> directories where ERL should look for .beam files? This is equivalent to
>> the CLASSPATH we set in Java.
>> The aim is to have erlang look for default directories rather than having
>> them passed using the -pa option to ERL.
>
> ERL_LIBS may be what you want.
>
> Cheers,
>
> DBM
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list