I'm trying to do this guide of elixir distributed tasks but I am running in troubles with this exception:
** (EXIT from #PID<0.62.0>) an exception was raised:
** (BadFunctionError) expected a function, got: #Function<20.50752066/0 in :erl_eval.expr/5>
:erlang.apply/2
[error] Error in process #PID<8796.100.0> on node :"[email protected]" with exit value:
{{:badfun, #Function<20.50752066/0 in :erl_eval.expr/5>},
[{:erlang, :apply, 2, []}]}
I start machine one with: iex --name [email protected] --cookie foo and run:
iex([email protected])1> defmodule Hello do
iex([email protected])1> def world, do: IO.puts "hello world"
iex([email protected])1> end
Then start machine two with: iex --name [email protected] --cookie foo. And try to spawn Hello.world function:
Node.spawn_link :"[email protected]", fn -> Hello.world end
After this, the error is displayed.
MORE INFO:
On machine one Node.list returns [:"[email protected]"]
Onmachine two Node.list returns [:"[email protected]"]
epmd -names on machine one returns:
epmd: up and running on port 4369 with data:
name gold at port 37295
epmd -names on machine two returns:
epmd: up and running on port 4369 with data:
name gold at port 39738
@GianFF you need to guarantee they are running exactly the same Erlang version. For production, we typically compile our code in a single machine and distribute it across, to guarantee the same version everywhere.
If you cannot guarantee the same version, then you must avoid anonymous function and always used named versions, such as:
Node.spawn_link :"[email protected]", &Hello.world/0
Node.spawn_link :"[email protected]", Hello, :world, []
@josevalim thanks you very much! I will try with this changes... but what about to add this on the docs that I mentioned? (http://elixir-lang.org/getting-started/mix-otp/distributed-tasks-and-configuration.html#distributed-tasks)
Should we improve the error message when value is a fun?
On 19 Apr 2017 11:06 pm, "Gian Franco Fioriello" notifications@github.com
wrote:
@josevalim https://github.com/josevalim thanks you very much! I will
try with this changes... but what about to add this on the docs that I
mentioned? (http://elixir-lang.org/getting-started/mix-otp/
distributed-tasks-and-configuration.html#distributed-tasks)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/elixir-lang/elixir/issues/6013#issuecomment-295465373,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB6JTYc_Jy9oBNL83EDGsTalvZ5KA5gdks5rxoVVgaJpZM4NBHu-
.
Most helpful comment
@GianFF you need to guarantee they are running exactly the same Erlang version. For production, we typically compile our code in a single machine and distribute it across, to guarantee the same version everywhere.
If you cannot guarantee the same version, then you must avoid anonymous function and always used named versions, such as: