Erlang shell停止加载我的模块 [英] Erlang shell stopped loading my modules
问题描述
cd myprojectdir
erl
(erlang shell)。
c(房间)。
{ok,R} = room:go()。
然后我可以使用gen_server将消息发送到R,与房间模块进行交互。
我开始在一个牛仔路由分支。我看到事情工作正常,当我看着它,我正在收到编译错误。所以我回到了我的主分公司。在shell中仍然有错误,甚至回滚一些提交,hm。
当我尝试调用room:go()时,其他模块打印为code>为undef 。如果我们依次编译它们,那么空格:go()将会工作。
房间打开桌子,桌子启动时钟,座位和游戏,游戏开始董事会和行动。
https://github.com / quantumproductions / tunnel
2> C(游戏)。
{ok,game}
3>游戏:去()。
**异常退出:undef
在功能板:go / 0
调用为板:go()
从游戏调用:init / 1(game.erl,line来自gen_server的
:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
4> C(板)。
{ok,board}
5>游戏:去()。
**异常退出:undef
在函数动作中:go / 0
称为动作:go()
从游戏调用:init / 1(game.erl,line来自gen_server的
:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
6> C(动作)。
{ok,actions}
7>行动:去()。
{ok,< 0.93.0>}
8>游戏:去()。
{ok,< 0.95.0>}
9> C(房间)。
{ok,room}
10>房间:去()。
**异常退出:undef
在函数表中:go / 0
称为表:go()
从房间调用:tablePids / 2(room.erl,line 33)
从房间调用:init / 1(room.erl,第80行)
从gen_server调用:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
11> C(表)。
{ok,table}
12>房间:去()。
**异常退出:undef
在函数clock中:go / 0
调用为clock:go()
从表中调用:init / 1(table.erl,line来自gen_server的
:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
13> C(时钟)。
{ok,clock}
14>房间:去()。
**异常退出:undef
在功能座位:go / 0
调用为座位:go()
从表中调用:init / 1(table.erl,line 8)从gen_server调用
:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
15> C(座位)。
{ok,seats}
16>房间:去()。
**异常退出:undef
在功能厅:go / 0
称为hall:go()
从房间调用:init / 1(room.erl,line从gen_server调用
:init_it / 6(gen_server.erl,第328行)
从proc_lib调用:init_p_do_apply / 3(proc_lib.erl,第247行)
17> C(厅)。
{ok,hall}
18>房间:去()。
{ok,< 0.159.0>}
19>
=错误报告==== 29-Jan-2017 :: 17:37:45 ===
错误进程< 0.169.0>退出值为
{undef,[{s,s,[<0.159.0>,更新],[]}}}
=错误报告==== 29- Jan-2017 :: 17:37:46 ===
错误进程< 0.170.0>退出值为
{undef,[{s,s,[<0.159.0>,更新],[]}}}
=错误报告==== 29- Jan-2017 :: 17:37:47 ===
错误进程< 0.171.0>退出值为
{undef,[{s,s,[<0.159.0>,更新],[]}}}
=错误报告==== 29- Jan-2017 :: 17:37:48 ===
错误进程< 0.172.0>退出值为
{undef,[{s,s,[<0.159.0>,更新],[]}}}
=错误报告==== 29- Jan-2017 :: 17:37:49 ===
错误进程< 0.173.0>退出值为
{undef,[{s,s,[<0.159.0>,更新],[]}}}
=错误报告==== 29- Jan-2017 :: 17:37:50 ===
错误进程< 0.174.0>退出值:
{undef,[{s,s,[<0.159.0>,更新],[]}]}
每个go()函数只是为了方便
go() - >
gen_server:start_link(?MODULE,[],[])。
版本控制:
code> Erlang / OTP 19 [erts-8.2] [source] [64位] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V8.2(中止与^ G)
发生了什么? / p>
编辑:
s:s来自我的快捷方式模块
-module(s)。
-export([s / 2])。
%快捷键。
%发送
s(Pid,Message) - >
gen_server:call(Pid,Message)。
更新消息是在房间中的定时器上发送的,它尝试将更新发送到每个表。
编辑:
我已经更改了零代码。这是现在运行时会发生什么..这是因为我已经有* .beam文件?
=错误报告== == 29-Jan-2017 :: 17:50:19 ===
错误进程< 0.200.0>退出值:
{undef,[{s,s,[< 0.59.0>,更新],[]}]}
BREAK:(a) (p)roc信息(i)nfo(l)oaded
(v)ersion(k)ill(D)b-table(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座位.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(中止与^ G)
1> C(板)。
{ok,board}
2>呼叫)。
all.erl:没有这样的文件或目录
错误
3> C()。
**异常错误:未定义的shell命令c / 0
4> C(房间)。
{ok,room}
5> C(S)。
{ok,s}
6>房间:去()。
{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位] [smp:8:8] [异步线程:10] [hipe] kernel-poll:false] [dtrace]
Eshell V8.2(中止与^ G)
1> C(房间)。
{ok,room}
2>房间:去()。
{ok,<0.72.0>}
3>室:测试()。
所有4个测试通过。
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] -poll:false] [dtrace]
Eshell V8.2(中止与^ G)
1> C(房间)。
{ok,room}
2>房间:去()。
{ok,<0.72.0>}
3>室:测试()。
所有4个测试通过。
ok
4>
听起来像我的模块 s
没有在第一种情况下编译,特别是给我们看到你可以在代码工作的编辑中编译它。
错误
=错误报告==== 29-Jan-2017 :: 17:37:50 ===
错误处理< 0.174.0>退出值:
{undef,[{s,s,[<0.159.0>,更新],[]}]}
表示对模块 s
和函数 s
的调用参数< 0.159.0>
和更新
失败与undef。
Erlang将让您编译一个调用尚未定义的函数的模块,这就是为什么我们有像外部参照的工具。
如果您没有使用正确的构建工具,如 mix , rebar3 或 erlang.mk 我会建议你做。
This was working fine last week. I would open
cd myprojectdir
erl
(erlang shell).
c(room).
{ok, R} = room:go().
then I could use gen_server to send messages to R, interacting with my room module.
I started in a cowboy routing branch. I was seeing things work fine, when I looked at it today I was getting compile errors. So I rolled back to my master branch. Still got errors in the shell, even rolling back a few commits, hm.
When I try to call room:go(), the other modules are printed as undef
. If I compile each of them in turn, then room:go() will work.
room kicks off tables, tables kick off clocks, seats and game, game kicks off board and actions.
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],[]}]}
Each go() function is just a convenience for
go() ->
gen_server:start_link(?MODULE, [], []).
Versioning:
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)
What happened?
EDIT:
s:s is from my shortcut module
-module(s).
-export([s/2]).
% Shortcuts.
% Send
s(Pid, Message) ->
gen_server:call(Pid, Message).
The update message is sent on a timer in the Room, which tries to send update to each of the Tables.
EDIT:
I have changed ZERO code. Here's what happens when I run now.. is this because I already have the *.beam files?
=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>
It sounds to me like your module s
was not compiled in the first case, especially give we can see you do compile it in your edit where the code works.
The error
=ERROR REPORT==== 29-Jan-2017::17:37:50 ===
Error in process <0.174.0> with exit value:
{undef,[{s,s,[<0.159.0>,update],[]}]}
is saying the call to module s
and function s
with the arguments <0.159.0>
and update
failed with undef.
Erlang will let you compile a module that has calls to as yet undefined functions, which is why we have tools like xref.
If you are not using a proper build tool like mix, rebar3 or erlang.mk I would advise you do.
这篇关于Erlang shell停止加载我的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!