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

Joe Armstrong <>
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:


%% 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",
		       end, L);
    _ ->

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

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

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" :-)



On Wed, Oct 24, 2012 at 6:12 PM, David Mercer <> 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,
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list