【问题标题】:Rebar3 not "including" my non-application depsRebar3 不“包括”我的非应用程序部门
【发布时间】:2017-04-10 02:58:58
【问题描述】:

我有简单的功能:

do_stuff(_Whatever) ->
  jiffy:decode(<<"{\"foo\": \"bar\"}">>).

如您所见,它取决于库 jiffy。于是我加在rebar.config

{deps, [
  {cowboy, {git, "https://github.com/ninenines/cowboy", {tag, "2.0.0-pre.1"}}},
  {jiffy, {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}}
]}.
{relx, [{release, { myapp, "0.1.0" },
     [vizcerl,
      sasl
      ]},

    %{sys_config, "./config/sys.config"},
    %{vm_args, "./config/vm.args"},

    {dev_mode, true},
    {include_erts, false},

    {extended_start_script, true}]
}.

但是当我运行 rebar3 run 并且程序 get 执行该操作时,我收到错误,指出该函数未定义。

编辑: 我运行 rebar3 tree 来检查 dep 是否被识别,结果如下:

└─ myapp─0.1.0 (project app)
   ├─ cowboy─2.0.0-pre.1 (git repo)
   │  ├─ cowlib─1.0.0 (git repo)
   │  └─ ranch─1.0.0 (git repo)
   └─ jiffy─0.14.8 (git repo)

【问题讨论】:

  • 您是否先运行rebar3 upgrade。如果我是正确的,它将在 deps 目录中安装所有必要的依赖项。
  • 当然...我也清理了所有东西。编辑:我刚刚做了 rebar3 升级,没有任何改变。
  • @Pascal 另外值得注意的是,cowboy 有效,而 jiffy 无效
  • 愚蠢的问题,但是如果你用erlc编译它会得到什么?
  • @OnorioCatenacci 愚蠢的问题,这不是用于编译单个文件吗?我该如何为整个项目做到这一点?

标签: erlang rebar3


【解决方案1】:

jiffy 需要一个不属于 rebar 的端口编译器插件。您可以在 rebar.config 中进行如下配置:

{plugins, [
    { pc, {git, "git@github.com:blt/port_compiler.git", {branch, "master"}}}
]}.
{overrides,
 [{override, jiffy, [
     {plugins, [pc]},
     {artifacts, ["priv/jiffy.so"]},
     {provider_hooks, [
         {post,
             [
             {compile, {pc, compile}},
             {clean, {pc, clean}}
             ]
          }]
      }
  ]}
]}.

【讨论】:

  • 这是答案的一部分。我需要将它添加到应用程序中。我认为应用程序列表是为了开始......而且似乎不是。但是在我添加了你的部分并将 jiffy 添加到应用程序列表之后,它似乎可以工作或至少不会崩溃
  • 我相信您需要向应用程序添加 jiffy,因为需要初始化 nif。无论如何,应用程序适用于您希望包含在您的发布/环境中的所有应用程序,无论它们是否需要启动
  • 在我添加那个插件之前它已经崩溃了。我不知道有必要这样做。
猜你喜欢
  • 1970-01-01
  • 2020-08-22
  • 1970-01-01
  • 1970-01-01
  • 2016-11-12
  • 2020-11-09
  • 1970-01-01
  • 2016-02-09
  • 1970-01-01
相关资源
最近更新 更多