Rebar3 Raw Dependency问题及修复.

在一个Erlang应用里,  有可能会有对其他应用的依赖, 我们可以把这个依赖定义在rebar.config 文件中. 但是如果依赖的应用不符合rebar app的要求的结构, 编译的时候就会报这个错误("Dependency failure : Application jsonx not found at the top level of directory ...").


导致错误的原因包括但不限于

Cause 1  --> this is the error message given when someone adds a dependency that is not of the structure <appname>/src but instead like <appname>/apps/<something>/src or anything else.
Cause 2 --> This error also occurs, when the src/.app file isn't in the format src/.app.src.

那么如何fix这个错误呢, 如果依赖于一些Erlang程序库, 但是这些程序库不符合rebar 对结构的要求, 我们可以在设置依赖的时候填上Raw标签.

基本上有两个步骤

Step 1) 修改应用的配置文件rebar.config, 加入以下几行. 这个用于加载一个plugin, 该plugin可以帮助处理raw的依赖库.

{plugins, [
    {rebar_raw_resource,
        {git, "git://github.com/basho/rebar_raw_resource.git",
        {branch, "master"}}}
]}.


Step 2)  修改依赖库的配置文件rebar.config, 加入raw 标签


{deps, [
    . . .
    {mydep1, {raw, {mydep1-resource-specification} }},
    {mydep2, {raw, {mydep2-resource-specification}, [raw-options] }},
    . . .
]}.


比如原来是这样,假设jsonx库不符合rebar应用结构

{erl_opts, [debug_info]}.
{deps, 
 [
  {emqttc, {git, "https://github.com/emqtt/emqttc"}},
  {gen_tracker, {git, "https://github.com/erlyvideo/gen_tracker.git"}},
  {iso8601, {git, "https://github.com/erlsci/iso8601.git", {tag, "1.2.2"}}},
  {jsonx, {git, "https://github.com/lukyanov/jsonx.git"}},
 ]}.

我们为jsonx加入 raw标签后是这样,就是在原来的基础上wrap一个raw 标签

{erl_opts, [debug_info]}.
{deps, 
 [
  {emqttc, {git, "https://github.com/emqtt/emqttc"}},
  {gen_tracker, {git, "https://github.com/erlyvideo/gen_tracker.git"}},
  {iso8601, {git, "https://github.com/erlsci/iso8601.git", {tag, "1.2.2"}}},
  {jsonx, {raw, {git, "https://github.com/lukyanov/jsonx.git"}}},
 ]}.


这两个步骤以后就可以运行rebar3 来编译了, rebar3会先把插件rebar_raw_resource下载下来,然后用这个插件来帮忙处理RAW依赖库.



##博客仅作个人记录##




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值