Erlang氮气教程项目不起作用

Erlang氮气教程项目不起作用,erlang,nitrogen,Erlang,Nitrogen,下面是氮气项目页面上的教程: 当我把浏览器指向localhost:8000时,它就不工作了。 我怀疑这与以下命令有关: make rel_inets; /home/david/programming/erlang/nitrogen/nitrogen/rel/nitrogen/lib/erlware_commons/src/ec_cmd_log.erl:160:5: ambiguous call of overridden auto-imported BIF error/3 **-** use

下面是氮气项目页面上的教程:

当我把浏览器指向localhost:8000时,它就不工作了。 我怀疑这与以下命令有关:

make rel_inets;

/home/david/programming/erlang/nitrogen/nitrogen/rel/nitrogen/lib/erlware_commons/src/ec_cmd_log.erl:160:5: ambiguous call of overridden auto-imported BIF error/3
**-** use erlang:error/3 or "-compile({no_auto_import,[error/3]})." to resolve name clash Compiling /home/david/programming/erlang/nitrogen/nitrogen/rel/nitrogen/lib/erlware_commons/src/ec_cmd_log.erl failed: ERROR: compile failed while processing /home/david/programming/erlang/nitrogen/nitrogen/rel/nitrogen/lib/erlware_commons: rebar_abort make[4]: *** [Makefile:12: compile] Error 1
有人知道出了什么问题吗?函数名之间似乎有冲突。 我安装了最新的erlang 24.0.1,但仍然有相同的行为。 谢谢

有人知道出了什么问题吗

下面是一个示例…Erlang定义了一个函数error/2,称为BIF或内置函数,可以这样调用:

-module(a).
-compile(export_all).


go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
在外壳中:

4> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}

5> a:go(1, 2).
hello
ok

6> a:go(11, 2).
** exception error: bad_arg
     in function  a:go/2
        called as a:go(11,2)
7> 
8> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported

a.erl:9: Warning: ambiguous call of overridden auto-imported BIF error/2
 - use erlang:error/2 or "-compile({no_auto_import,[error/2]})." to resolve name clash
{ok,a}
现在,看看如果在模块中定义一个名为error/2的函数会发生什么:

-module(a).
-compile(export_all).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
-module(a).
-compile(export_all).
-compile({no_auto_import,[error/2]}).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").


11> c(a).       
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}
在外壳中:

4> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}

5> a:go(1, 2).
hello
ok

6> a:go(11, 2).
** exception error: bad_arg
     in function  a:go/2
        called as a:go(11,2)
7> 
8> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported

a.erl:9: Warning: ambiguous call of overridden auto-imported BIF error/2
 - use erlang:error/2 or "-compile({no_auto_import,[error/2]})." to resolve name clash
{ok,a}
警告告诉您,如果您真的想调用erlang的error/2,那么应该在函数名之前加上定义函数的模块名,即erlang模块:

…或者,如果要调用错误/2的版本,请输入模块指令:

 -compile({no_auto_import,[error/2]}).
在模块顶部:

-module(a).
-compile(export_all).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
-module(a).
-compile(export_all).
-compile({no_auto_import,[error/2]}).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").


11> c(a).       
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}
请注意,代码中的问题只是一个警告,当我按照最初编写的方式运行程序时,erlang调用模块中定义的error/2版本,而不是erlang模块中的版本

奇怪的是:erlang模块中没有定义错误/3

有人知道出了什么问题吗

下面是一个示例…Erlang定义了一个函数error/2,称为BIF或内置函数,可以这样调用:

-module(a).
-compile(export_all).


go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
在外壳中:

4> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}

5> a:go(1, 2).
hello
ok

6> a:go(11, 2).
** exception error: bad_arg
     in function  a:go/2
        called as a:go(11,2)
7> 
8> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported

a.erl:9: Warning: ambiguous call of overridden auto-imported BIF error/2
 - use erlang:error/2 or "-compile({no_auto_import,[error/2]})." to resolve name clash
{ok,a}
现在,看看如果在模块中定义一个名为error/2的函数会发生什么:

-module(a).
-compile(export_all).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
-module(a).
-compile(export_all).
-compile({no_auto_import,[error/2]}).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").


11> c(a).       
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}
在外壳中:

4> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}

5> a:go(1, 2).
hello
ok

6> a:go(11, 2).
** exception error: bad_arg
     in function  a:go/2
        called as a:go(11,2)
7> 
8> c(a).
a.erl:2: Warning: export_all flag enabled - all functions will be exported

a.erl:9: Warning: ambiguous call of overridden auto-imported BIF error/2
 - use erlang:error/2 or "-compile({no_auto_import,[error/2]})." to resolve name clash
{ok,a}
警告告诉您,如果您真的想调用erlang的error/2,那么应该在函数名之前加上定义函数的模块名,即erlang模块:

…或者,如果要调用错误/2的版本,请输入模块指令:

 -compile({no_auto_import,[error/2]}).
在模块顶部:

-module(a).
-compile(export_all).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").
-module(a).
-compile(export_all).
-compile({no_auto_import,[error/2]}).

error(X, Y) ->
   io:format("X = ~w, Y = ~w~n", [X,Y]). 

go(X, Y) ->
    case X > 10 of
        true -> error(bad_arg, [X, Y]);
        false -> ok
    end,
    io:format("hello\n").


11> c(a).       
a.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,a}
请注意,代码中的问题只是一个警告,当我按照最初编写的方式运行程序时,erlang调用模块中定义的error/2版本,而不是erlang模块中的版本


奇怪的是:erlang模块中没有定义错误/3。

谢谢@7stud,这非常有用。可能OTP 24中有错误/3。请参阅我在该文件第26行中找到的内容:最新版本的氮气是在OTP 24之前发布的,我正在使用OTP 24。@Bucephalus,第25行的评论说:%%避免与Erlang/OTP 24中添加的错误/3 BIF冲突。氮的最新版本是在OTP 24之前发布的,我正在使用OTP 24然后,您必须降级您的Erlang或修改氮源代码,以便在调用error/3的地方包括第26行这样的行。谢谢@7stud。我在erlang slack中提出了这个问题,氮气项目经理说他将在本周解决这个问题。我有很多关于二郎的学习要做,所以我会在这段时间里继续做其他的事情,并坚持OTP24。谢谢你的帮助-这是非常有见地的。问题已经解决了。氮最终依赖于qdate,qdate依赖于erlware_commons,但绑定到erlware_commons的旧版本。这已更新,qdate 0.6.0已标记并与OTP24一起使用。感谢@7stud,这非常有用。可能OTP 24中有错误/3。请参阅我在该文件第26行中找到的内容:最新版本的氮气是在OTP 24之前发布的,我正在使用OTP 24。@Bucephalus,第25行的评论说:%%避免与Erlang/OTP 24中添加的错误/3 BIF冲突。氮的最新版本是在OTP 24之前发布的,我正在使用OTP 24然后,您必须降级您的Erlang或修改氮源代码,以便在调用error/3的地方包括第26行这样的行。谢谢@7stud。我在erlang slack中提出了这个问题,氮气项目经理说他将在本周解决这个问题。我有很多关于二郎的学习要做,所以我会在这段时间里继续做其他的事情,并坚持OTP24。谢谢你的帮助-这是非常有见地的。问题已经解决了。氮最终依赖于qdate,qdate依赖于erlware_commons,但绑定到erlware_commons的旧版本。这已更新,qdate 0.6.0已标记并与OTP24一起使用。