Question

This is my .erlang file:

code:add_path("/home/root/projects/myapp/ebin").
code:add_path("/home/root/projects/esmtp/ebin").
application:load(esmtp),
application:set_env(esmtp, smarthost, {"localhost",25}),
application:set_env(esmtp, default_from, "<stuff>"),
application:start(esmtp).

When I run:

erl -boot myapp 

it fails:

{"init terminating in do_boot",{'cannot get bootfile','myapp.boot'}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

But if I run:

erl -boot myapp -pa /home/root/projects/myapp/ebin

It works fine. That leads me to believe that -pa on the command line is treated differently than code:add_path() in the .erlang file. I know the .erlang file is in effect, because esmtp loads and runs correctly. What's the difference between -pa and code:add_path()?

Was it helpful?

Solution

The .erlang file is read and executed after the boot file is loaded, so the path has not been added when erlang is looking for the boot file.

The -pa on the other hand is added before the vm starts to look for the boot file so then it is found.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top