remote execution of funs in shell =/= in erts

Peter-Henry Mander <>
Wed Nov 24 10:33:24 CET 2004

Hi Gurus,

After going through the checklist for setting up communicating nodes
(same Erlang cookies, up to date /etc/hosts file etc...) I tried to
execute a function on the remote node from the shell, which worked

()2> spawn('',fun() -> group_leader(whereis(init),self()),io:format("wow!~n",[]) end).

The other end obliged with:

()2> wow!

But using a compiled beam only reproduced the desired results if the two
beams matched, i.e. the same source was compiled on both nodes. If
there's a mismatch it won't work, reporting that:

=ERROR REPORT==== 24-Nov-2004::09:03:48 ===
Error in process <0.40.0> on node '' with exit value: {{badfun,#Fun<test_remote.0.70372976>},[{error_handler,undefined_lambda,3}]}

** exited: {{badfun,#Fun<test_remote.0.70372976>},
            [{error_handler,undefined_lambda,3}]} **

When both nodes have equivalent beams everything works as it does with
the shell example.

So I guess that there's a difference between how the shell executes
remote funs and how the Erlang runtime executes remote funs. How do
nodes communicate what appears to be version information or beam digest
or checksums beween them? Is this documented (otherwise than by reading
code :-)? Is it possible for the runtime to execute a remote fun without
the corresponding beam being available on the remote node, like the
shell appears to do?



test()-> spawn_link('',fun f/0).
f()-> group_leader(whereis(init),self()),io:format("wow!~n",[]).

"The Tao of Programming
 flows far away 
 and returns 
 on the wind of morning."

More information about the erlang-questions mailing list