Sepehr Samini
Sepehr Samini

Reputation: 1055

How run an Erlang application inside the Erlang shell

I have an Erlang application and I can compile it easily and run it by using basho rebar which makes an stand-alone escript executable file. I run it from command line like: ./myapp myconfig.config

My questio is that how can I run it inside Erlang shell. This application has four other applications as dependency. Rebar compile all of the easily. But I need to run this application from inside the shell like:

erl -noshell -name node1@machine -run test start parameter1 -s init stop;

But I don't know in which path I should run it. When I try it in "ebin" folder (where beam files are located), dependencies are not accessible. As I see each dependency applications has it own "ebin" folder. So how can I run my application by "erl -noshell" command (consider dependency applications)? Rebar handles all these things automatically.

Upvotes: 4

Views: 1334

Answers (1)

Martin Törnwall
Martin Törnwall

Reputation: 9599

A typical directory structure for a Rebar-powered OTP application is something like this:

/
  src/
  ebin/
  deps/
    dep1/
      src/
      ebin/
    dep2/
      src/
      ebin/

So, if you're in the root directory of your project, you can point erl to the right place with the -pa argument. To tell it where to find both your application's and its dependencies' BEAM files, try the following:

erl [...] -pa ebin -pa deps/*/ebin

Upvotes: 9

Related Questions