Starting an Erlang slave node in escript fails when using custom Erlang in Ubuntu 10.4
- by Adam Lindberg
I have the following escript:
#!/usr/bin/env escript
%%! -name test_starter@127.0.0.1
main(_) ->
NodeName = test,
Host = '127.0.0.1',
Args = "",
{ok, _Node} = slave:start_link(Host, NodeName, Args),
io:format("Node started successfully!").
When running it on Ubuntu 10.04 I get this:
$ ./start_slave
Node started successfully!
$
I want to install my own Erlang (latest version, debug compiled files for dialyzer etc) since the stock install of Erlang on Ubuntu lacks some features. I put my Erlang binaries inside ~/Applications/bin. Starting Erlang normally works, and starting slave nodes inside an Erlang shell works as well.
However, now my escript doesn't work. After about 60 seconds it returns an error:
$ ./start_slave
escript: exception error: no match of right hand side value {error,timeout}
Even if I change the first line to the escript to use my erlang version, it still does not work:
#!/home/user/Applications/bin/escript
The slave node is started with a call to erlang:open_port/2 which seems to be using sh which in turn does not read my .bashrc file that sets my custom PATH environment variable. The timeout seems to occur when slave:start_link/3 waits for the slave node to respond, which it never does.
How can I roll my own installation of Erlang and start slave nodes inside escripts on Ubuntu 10.4?