Erlang shell 停止加载我的模块

Erlang shell stopped loading my modules

上周运行良好。我会打开

cd myprojectdir erl (erlang shell). c(room). {ok, R} = room:go().

然后我可以使用 gen_server 向 R 发送消息,与我的房间模块交互。

我从牛仔路由分支开始。我看到一切正常,当我今天看它时,我遇到了编译错误。所以我回滚到我的主分支。 shell 中仍然有错误,甚至回滚了一些提交,嗯。

当我尝试调用 room:go() 时,其他模块打印为 undef。如果我依次编译它们中的每一个,那么 room:go() 将起作用。

房间从桌子开始,桌子从时钟、座位和游戏开始,游戏从棋盘和动作开始。

https://github.com/quantumproductions/tunnel

2> c(game).
{ok,game}
3> game:go().
** exception exit: undef
     in function  board:go/0
        called as board:go()
     in call from game:init/1 (game.erl, line 57)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
4> c(board).
{ok,board}
5> game:go().
** exception exit: undef
     in function  actions:go/0
        called as actions:go()
     in call from game:init/1 (game.erl, line 58)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
6> c(actions).
{ok,actions}
7> actions:go().
{ok,<0.93.0>}
8> game:go().
{ok,<0.95.0>}
9> c(room).
{ok,room}
10> room:go().
** exception exit: undef
     in function  table:go/0
        called as table:go()
     in call from room:tablePids/2 (room.erl, line 33)
     in call from room:init/1 (room.erl, line 80)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
11> c(table).
{ok,table}
12> room:go().
** exception exit: undef
     in function  clock:go/0
        called as clock:go()
     in call from table:init/1 (table.erl, line 7)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
13> c(clock).
{ok,clock}
14> room:go().
** exception exit: undef
     in function  seats:go/0
        called as seats:go()
     in call from table:init/1 (table.erl, line 8)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
15> c(seats).
{ok,seats}
16> room:go().
** exception exit: undef
     in function  hall:go/0
        called as hall:go()
     in call from room:init/1 (room.erl, line 81)
     in call from gen_server:init_it/6 (gen_server.erl, line 328)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
17> c(hall).
{ok,hall}
18> room:go().
{ok,<0.159.0>}
19>
=ERROR REPORT==== 29-Jan-2017::17:37:45 ===
Error in process <0.169.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

=ERROR REPORT==== 29-Jan-2017::17:37:46 ===
Error in process <0.170.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

=ERROR REPORT==== 29-Jan-2017::17:37:47 ===
Error in process <0.171.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

=ERROR REPORT==== 29-Jan-2017::17:37:48 ===
Error in process <0.172.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

=ERROR REPORT==== 29-Jan-2017::17:37:49 ===
Error in process <0.173.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

=ERROR REPORT==== 29-Jan-2017::17:37:50 ===
Error in process <0.174.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

每个 go() 函数只是为了方便

go() ->
  gen_server:start_link(?MODULE, [], []).

版本控制:

Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.2  (abort with ^G)

发生了什么事?

编辑:

s:s 来自我的快捷模块

-module(s).
-export([s/2]).
% Shortcuts.

% Send
s(Pid, Message) ->
  gen_server:call(Pid, Message).

更新消息在房间中的计时器上发送,它会尝试向每个表发送更新。

编辑:

我已经更改了零代码。这是我现在 运行 时发生的情况..这是因为我已经有了 *.beam 文件吗?

=ERROR REPORT==== 29-Jan-2017::17:50:19 ===
Error in process <0.200.0> with exit value:
{undef,[{s,s,[<0.59.0>,update],[]}]}

BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C~/tunnel:.ls
actions.beam    clock.beam  hall.beam   s.erl       table.erl
actions.erl clock.erl   hall.erl    seats.beam  timer.erl
board.beam  game.beam   room.beam   seats.erl
board.erl   game.erl    room.erl    table.beam
~/tunnel:.erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.2  (abort with ^G)
1> c(board).
{ok,board}
2> c(all).
all.erl: no such file or directory
error
3> c().
** exception error: undefined shell command c/0
4> c(room).
{ok,room}
5> c(s).
{ok,s}
6> room:go().
{ok,<0.96.0>}
7>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C~/tunnel:.erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.2  (abort with ^G)
1> c(room).
{ok,room}
2> room:go().
{ok,<0.72.0>}
3> room:test().
  All 4 tests passed.
ok
4>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C~/tunnel:.
~/tunnel:.erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.2  (abort with ^G)
1> c(room).
{ok,room}
2> room:go().
{ok,<0.72.0>}
3> room:test().
  All 4 tests passed.
ok
4>

在我看来你的模块 s 在第一种情况下没有被编译,特别是我们可以看到你在代码工作的编辑中编译了它。

错误

=ERROR REPORT==== 29-Jan-2017::17:37:50 ===
Error in process <0.174.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}

表示使用参数 <0.159.0>update 调用模块 s 和函数 s 因 undef 而失败。

Erlang 将允许您编译一个调用尚未定义的函数的模块,这就是为什么我们有 tools like xref.

如果您没有使用像 mix, rebar3 or erlang.mk 这样的合适的构建工具,我建议您这样做。