1
votes

Hello I am writing module for mongooseim(ejabberd fork) chat, I want some external library from github. I added it to rebar config.

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

it is downloading to /deps directory while when I run project I have the following error: call to undefined function jsx:encode

I find the directory where /ebin directory copying (/dev/lib/ebin) and copy ebin directory from jsx there. Then function is accessible. It is impossible to do this manually each time, how can I make it with rebar? Thank you.

Update: I actually build it with make dev rel:

the following happens:

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
1
If you start it with erl you can add with -pa ebin/ deps/*/ebin/ the search path for dependencies - it's just an idea maybe you can do something similar to solve your problemSir l33tname
@Sirl33tname I start it with make, look at my update.Slow Harry
@Sirl33tname it starts right, it builds wrong. I want rebar put ebin from some library to the specific directory while it is not.Slow Harry
@Sirl33tname ohh I solved it thank you anywaySlow Harry
nice, so please add your solution as answer for other usersSir l33tname

1 Answers

3
votes

In order to add dependency to mongooseim you should first add it to 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"}}}
]}.

then when u do make it should be downloaded into /deps directory.

Then take a look at /rel/reltool.config file.

Here you find something like:

{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}]}
}

Your dependency should work. Look at rel/mongooseim/lib or dev/mongooseim_odbc*/lib directory. In my case there is jsx-2.0.1 with ebin directory in it.