【问题标题】:Can't add dependecy to Mongooseim[erlang]无法将依赖项添加到 Mongooseim [erlang]
【发布时间】:2014-10-11 05:05:27
【问题描述】:

您好,我正在为 mongooseim(ejabberd fork) 聊天编写模块,我想要一些来自 github 的外部库。我将它添加到钢筋配置中。

    {jsx, ".*", {git, "git://github.com/talentdeficit/jsx", {branch, "master"}}}

当我运行项目时,它正在下载到 /deps 目录,但出现以下错误:call to undefined function jsx:encode

我找到 /ebin 目录复制的目录(/dev/lib/ebin)并从 jsx 那里复制 ebin 目录。然后功能是可访问的。每次都手动做是不可能的,我怎么能用钢筋做呢?谢谢。

更新: 我实际上是用 make dev rel 构建的:

会发生以下情况:

devrel: $(DEVNODES)

$(DEVNODES): rebar deps compile deps_dev
    @echo "building $@"
    (cd rel && ../rebar generate -f target_dir=../dev/mongooseim_$@ overlay_vars=./reltool_vars/$@_vars.config)
    cp apps/ejabberd/src/*.erl `ls -dt dev/mongooseim_$@/lib/ejabberd-2.1.8*/ebin/ | head -1`
ifeq ($(shell uname), Linux)
    cp -R `dirname $(shell readlink -f $(shell which erl))`/../lib/tools-* dev/mongooseim_$@/lib/
else
    cp -R `which erl`/../../lib/tools-* dev/mongooseim_$@/lib/
endif

【问题讨论】:

  • 如果您使用 erl 启动它,您可以使用 -pa ebin/deps/*/ebin/ 添加依赖项的搜索路径 - 这只是一个想法,也许您可​​以做一些类似的事情来解决您的问题跨度>
  • @Sirl33tname 我以make 开头,看看我的更新。
  • @Sirl33tname 它开始正确,但构建错误。我希望 rebar 将 ebin 从某个库放到特定目录,而它不是。
  • @Sirl33tname 哦,我解决了,还是谢谢你
  • 很好,所以请将您的解决方案添加为其他用户的答案

标签: erlang ejabberd rebar mongoose-im


【解决方案1】:

为了添加对 mongooseim 的依赖,您应该首先将其添加到 rebar.config

{deps, [
    {cuesport, ".*", {git, "git://github.com/goj/cuesport.git", {branch, "master"}}},
    {redo, ".*", {git, "git://github.com/JacobVorreuter/redo.git", {branch, "master"}}},
    {exml, "2.1.4", {git, "git://github.com/esl/exml.git", {tag, "2.1.4"}}},
    {lager, ".*", {git, "git://github.com/basho/lager.git"}},
    {cowboy, "0.8.6", {git, "git://github.com/extend/cowboy.git", "0.8.6"}},
    {folsom, ".*", {git, "git://github.com/boundary/folsom.git", {branch, "master"}}},
    {mochijson2, ".*", {git, "git://github.com/bjnortier/mochijson2.git", {branch, "master"}}},
    {alarms, ".*", {git, "git://github.com/chrzaszcz/alarms.git", {branch, "master"}}},
    {p1_cache_tab, ".*", {git, "git://github.com/processone/cache_tab"}},
    {p1_stringprep, ".*", {git, "git://github.com/processone/stringprep.git", "9e9e0f8dbe6a70ef36e1d4436b458ca5a77fbcfb"}},
    My dependency-->{jsx, ".*", {git, "git://github.com/talentdeficit/jsx", {branch, "master"}}}
]}.

那么当你做make时,它应该被下载到/deps目录中。

然后看看 /rel/reltool.config 文件。

在这里你可以找到类似的东西:

{sys, [ ...
   {app, inets, [{incl_cond, include}]},
   {app, exml, [{incl_cond, include}]},
   {app, ranch, [{incl_cond, include}]},
   {app, cowboy, [{incl_cond, include}]},
   {app, bear, [{incl_cond, include}]},
   {app, folsom, [{incl_cond, include}]},
   {app, mochijson2, [{incl_cond, include}]},
   {app, syntax_tools, [{incl_cond, include}]},
   {app, p1_cache_tab, [{incl_cond, include}]},
   {app, alarms, [{incl_cond, include}]},
   My dependency->{app, jsx, [{incl_cond, include}]}
}

你的依赖应该有效。查看 rel/mongooseim/libdev/mongooseim_odbc*/lib 目录。就我而言,其中有带有 ebin 目录的 jsx-2.0.1。

【讨论】:

    猜你喜欢
    • 2013-07-12
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 1970-01-01
    相关资源
    最近更新 更多