问题出在rebar,rebar3没测试。
今天用rebar管理项目,在添加一个类库时遇到问题,类库地址为:
https://github.com/tonyg/erlang-rfc4627
rebar.config里面这么写:
{deps, [
{erlang-rfc4627, ".*", {git, "git://github.com/tonyg/erlang-rfc4627.git", "master"}},
]}.
这样写不行,查了很久,才发现问题出在erlang-rfc4627这个字段。
使用erlang读取文件:
$erl
1>file:consult("rebar.config").
{error,{5,erl_parse,"bad term"}}
原因很可能是,erlang中的原子不以-符号连接,erlang-rfc4627可以改名为erlang_rfc4627,或者'erlang-rfc4627'。
改为erlang_rfc4627继续。
获取所有依赖还是失败,失败原因:
{name_mismatch,...
{expected,erlang_rfc4627},
{has,rfc4627_jsonrpc}}}.
参考:Respository Name and application name conflicts
这是因为ebin/rfc4627_jsonrpc.app写着:
{application, rfc4627_jsonrpc,
...}.
而rebar下载的目录名称为erlang_rfc4627, 跟rfc4627_jsonrpc不匹配。
最后改为:
{deps, [
{rfc4627_jsonrpc, ".*", {git, "git://github.com/tonyg/erlang-rfc4627.git", "master"}}
]}.
名称改为app中的项目名称即可。