rebar3_elixir_compile icon indicating copy to clipboard operation
rebar3_elixir_compile copied to clipboard

All dependencies have to be explicitly stated

Open CrowdHailer opened this issue 7 years ago • 3 comments

This plug in appears to pull all the dependencies of a hex project. however unless the are all added to the list of deps then they are not compiled/included.

I have a small rebar3 project using Ace, an elixir dependency which has further dependencies. This is the section of my rebar.config file which should only need to have ace declared https://github.com/CrowdHailer/greetings-ace-raxx-erlang-example/blob/master/rebar.config#L3-L6

CrowdHailer avatar May 20 '18 18:05 CrowdHailer

This plug in appears to pull all the dependencies of a hex project. however unless the are all added to the list of deps then they are not compiled/included.

what do you mean exactly? That it doesn't take the deps from your mix file or smth else?

benoitc avatar May 20 '18 20:05 benoitc

Yes the deps of an included project are not pulled from the projects mix.exs when using rebar3 eunit or rebar shell

For example if I update my rebar.config to the following.

{erl_opts, [debug_info]}.
{deps, [
  {ace, {elixir, "ace", "0.16.4"}}
  % {raxx, {elixir, "raxx", "0.15.4"}},
  % {hpack, "0.2.3", {pkg, hpack_erl}},
  % {cookie, {elixir, "cookie", "0.1.0"}}
]}.

{plugins, [
    { rebar3_elixir_compile, ".*", {git, "https://github.com/barrel-db/rebar3_elixir_compile.git", {branch, "master"}}}
]}.

{provider_hooks, [
  {pre, [{compile, {ex, compile}}]}
]}.

{elixir_opts,
  [
    {env, dev}
  ]
}.

{shell, [{apps, [greetings]}]}.

When I run rebar3 shell I see:

==> raxx
Compiling 13 files (.ex)
Generated raxx app
==> ace
Compiling 27 files (.ex)
Generated ace app
===> Compiling ace
===> Compiling greetings
===> Adding Elixir Libs
src/greetings_www.erl:3: Warning: behaviour 'Elixir.Raxx.Server' undefined

There is that line that says the dependencies of my dependency where compile. But only the explicitly declared dependency is available in the shell. concretely my project depends on ace, and ace depends on raxx.

2> 'Elixir.Ace.HTTP.Service':module_info(). 
[{module,'Elixir.Ace.HTTP.Service'}, ...
3> 'Elixir.Raxx':module_info().
** exception error: undefined function 'Elixir.Raxx':module_info/0

CrowdHailer avatar May 20 '18 21:05 CrowdHailer

I think I am suffering the same problem.

  • I have an Erlang app.
  • I have an elixir app in elixir_libs/pet_repo.
  • pet_repo depends on ecto and postgresx with proper configuration.
  • The plugin compiles and puts all elixir dependencies (ecto and postgrex among them) in _build.
  • I add pet_repo to the applications of my erlang app.src file

At least with rebar shell, I cannot start my erlang app because dependency app files cannot be found:

1> application:ensure_all_started(pet).

=INFO REPORT==== 6-Sep-2018::08:42:58 ===
    application: logger
    exited: stopped
    type: temporary

=INFO REPORT==== 6-Sep-2018::08:42:58 ===
    application: elixir
    exited: stopped
    type: temporary

{error,{postgrex,{"no such file or directory",
                  "postgrex.app"}}}
2> 

I can try to build a PR the reproduce the problem in the plugin repo (demo).

aherranz avatar Sep 06 '18 07:09 aherranz