Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
Created September 14, 2012 16:22
Show Gist options
  • Save drewkerrigan/3722997 to your computer and use it in GitHub Desktop.
Save drewkerrigan/3722997 to your computer and use it in GitHub Desktop.
1. What's the best way to declare dependencies for erlang? I would have thought using rebar's transitive dependency management would be the way to go... put external dependencies in rebar.config, run 'rebar get-deps && rebar compile' and you're off to the races. But this thread indicates that this could break apps with shared dependencies. If both apps A and B depend on C, and C hoarks, then both apps A and B die, too.
http://stackoverflow.com/questions/11141198/when-to-use-erlang-applicationstart-or-included-applications-and-a-supervisor
2. Assuming that this thread was incorrect, and that rebar dependencies are the way to go, I'm having a teensy problem. I was following Dizzy's 2011 presentation (http://vimeo.com/22700527) and thought, sweet, I'll create a sample app and have it depend on ibrowse (very cool app).
REPRO:
1. make basic app
$ mkdir foo
$ cd foo
$ rebar create-app appid=foo
$ find .
.
./src
./src/foo_sup.erl
./src/foo.app.src
./src/foo_app.erl
2. verify compiles
$ rebar compile
==> foo (compile)
Compiled src/foo_app.erl
Compiled src/foo_sup.erl
3. add dependency
create rebar.config:
{deps, [
{ibrowse, ".*", {git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v4.0.1"}}}
]
}.
4. get deps
$ rebar get-deps
==> foo (get-deps)
Pulling ibrowse from {git,"git://github.com/cmullaparthi/ibrowse.git",
{tag,"v4.0.1"}}
Cloning into 'ibrowse'...
==> ibrowse (get-deps)
5. verify compiles
[todd@quebec-01 foo]$ rebar compile
==> ibrowse (compile)
Compiled src/ibrowse_lib.erl
Compiled src/ibrowse_lb.erl
Compiled src/ibrowse_app.erl
Compiled src/ibrowse_test.erl
Compiled src/ibrowse_sup.erl
Compiled src/ibrowse.erl
/home/todd/projects/erlang/foo/deps/ibrowse/src/ibrowse_http_client.erl:999: Warning: variable 'State' is unused
Compiled src/ibrowse_http_client.erl
==> foo (compile)
******************************************
Ok, now here is the part where I'm confused,
how is one supposed to declare the
******************************************
6. Add the dependency, 'ibrowse' to my foo application's list of dependencies...(http://www.erlang.org/doc/man/app.html)...
deps/ibrowse/ebin/ibrowse.app shows:
Application = ibrowse
Ok, so I'll update my src/foo.app.src from:
{application, foo,
[
{description, ""},
{vsn, "1"},
{registered, []},
{applications, [
kernel,
stdlib
]},
{mod, { foo_app, []}},
{env, []}
]}.
to
{application, foo,
[
{description, ""},
{vsn, "1"},
{registered, []},
{applications, [
kernel,
stdlib,
<<< added >>> ibrowse
]},
{mod, { foo_app, []}},
{env, []}
]}.
7. compile
$ rebar compile
8. verify compiles ok, and that the ebin/foo.app has been updated to include the ibrowse dependency...
{application,foo,
[{description,[]},
{vsn,"1"},
{registered,[]},
{applications,[kernel,stdlib,ibrowse]},
{mod,{foo_app,[]}},
{env,[]},
{modules,[foo_app,foo_sup]}]}.
Ok, looks good.
9. start the app, foo
$ erl -pa ebin/ -pa deps/ibrowse/ebin/
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:6:6] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.2 (abort with ^G)
1> application:start(foo).
{error,{not_started,ibrowse}}
Ok, that didn't work...
10. try starting ibrowse first, then foo
$ erl -pa ebin/ -pa deps/ibrowse/ebin/
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:6:6] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.2 (abort with ^G)
1> ibrowse:start().
{ok,<0.34.0>}
2> application:start(foo).
{error,{not_started,ibrowse}}
Ok, that's it. Any ideas what I'm doing wrong, or how I should go about debugging this app as it fails to startup?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment