Error compiling erlang package with rebar

Hi to all,
I have a strange behaviour when I compile some erlang library with mix. I’m working with riak_core. If I create an empty project with this dependency using rebar3 everything works fine but If I try to creating the same empty project in elixir I receive a strange error:

==> basho_poolboy (compile)
==> riak_core (compile)
Dependency not available: poolboy-0.8.1-p3 ({pkg,basho_poolboy})
ERROR: compile failed while processing /home/gpad/workspace/riak/riak_core_bug/deps/riak_core: rebar_abort
** (Mix) Could not compile dependency :riak_core, "/home/gpad/.mix/rebar compile skip_deps=true deps_dir="/home/gpad/workspace/riak/riak_core_bug/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile riak_core", update it with "mix deps.update riak_core" or clean it with "mix deps.clean riak_core"

I add to mix.exs this dependencies:

  defp deps do
    [
      {:poolboy, "~> 0.8.1-p3", hex: :basho_poolboy},
      {:riak_core, "~> 2.2", hex: :riak_core_ng}
    ]
  end

and receive this error:

Unchecked dependencies for environment dev:
* basho_poolboy (Hex package)
  could not find an app file at _build/dev/lib/basho_poolboy/ebin/basho_poolboy.app. This may happen if the dependency was not yet compiled, or you specified the wrong application name in your deps, or the dependency indeed has no app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies

I think that the problem is related in how rebar3 and mix manage the dependencies. Riak_core has this dependencies bashoo_poolboy, that is a fork of poolboy.

When I get the dependencies with rebar3 I have _build/default/lib/basho_poolboy/ebin/poolboy.app this with inside:

{application,poolboy,
             [{description,"A hunky Erlang worker pool factory"},
              {vsn,"0.8.1-p3"},
              {pkg_name,"basho_poolboy"},
              {applications,[kernel,stdlib]},
              {registered,[poolboy]},
              {maintainers,["basho","Heinz N. Gies"]},
              {licenses,["Apache"]},
              {links,[{"Github","https://github.com/basho/riak_sysmon"}]},
              {modules,[poolboy,poolboy_sup,poolboy_worker]}]}.

but in mix I have two folders, deps/poolboy/ and deps/basho_poolboy/ and the two app files are:

cat _build/dev/lib/poolboy/ebin/poolboy.app

{application,poolboy,
             [{description,"A hunky Erlang worker pool factory"},
              {vsn,"0.8.1-p3"},
              {pkg_name,"basho_poolboy"},
              {applications,[kernel,stdlib]},
              {registered,[poolboy]},
              {maintainers,["basho","Heinz N. Gies"]},
              {licenses,["Apache"]},
              {links,[{"Github","https://github.com/basho/riak_sysmon"}]},
              {modules,[poolboy,poolboy_sup,poolboy_worker]}]}.

and

cat _build/dev/lib/basho_poolboy/ebin/poolboy.app

{application,poolboy,
             [{description,"A hunky Erlang worker pool factory"},
              {vsn,"0.8.1-p3"},
              {pkg_name,"basho_poolboy"},
              {applications,[kernel,stdlib]},
              {registered,[poolboy]},
              {maintainers,["basho","Heinz N. Gies"]},
              {licenses,["Apache"]},
              {links,[{"Github","https://github.com/basho/riak_sysmon"}]},
              {modules,[poolboy,poolboy_sup,poolboy_worker]}]}.

What do you think?

As far as I understand, the rebar used by mix is a rebar 2, while riak_core needs to be compiled using rebar3.

I do know, that there were ways to specify which toolchain has to be used for a certain depenendecy. According to http://elixir-lang.org/docs/stable/mix/Mix.Tasks.Deps.html, there is the option :manager might do what you want.

Try to specify the dependency as follows:

{:riak_core, "~> 2.2", [hex: :riak_core_ng, manager: :rebar3]}

@NobbZ thanks for your help but I have a similar error.

I changed the dependencies in this way:

  defp deps do
    [
      {:poolboy, "~> 0.8.1-p3", [hex: :basho_poolboy, manager: :rebar3]},
      {:riak_core, "~> 2.2", [hex: :riak_core_ng, manager: :rebar3]}
    ]
  end

but I receive a similar error:

Running dependency resolution
All dependencies up to date
===> Compiling poolboy
Unchecked dependencies for environment dev:
* basho_poolboy (Hex package)
  could not find an app file at _build/dev/lib/basho_poolboy/ebin/basho_poolboy.app. This may happen if the dependency was not yet compiled, or you specified the wrong application name in your deps, or the dependency indeed has no app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies

the file _build/dev/lib/basho_poolboy/ebin/basho_poolboy.app doesn’t exist :frowning:

I really would like to test this and dive deeper into this but my ISP has
issues in hole Germany.

Can you give me some hints on how to investigate it?
I would use Elixir, otherwise I should return on the old, rock solid Erlang :wink:

No not really. I just had tried to get it to compile by trying different versions of Elixir, Mix and Rebar, perhaps diving into Mix’s code.

And even if I am online again, the about 6 hours offline yesterday evening had massively influenced my ability to work on an university project, and I need to catch up now. So I can’t help right now :frowning: Sorry.

I am getting an entirely different error?!

I made a new project, added the above two dependencies, and I get this error when running mix deps.get

* Getting basho_poolboy (Hex package)
** (MatchError) no match of right hand side value: nil
    (hex) lib/hex/scm.ex:85: Hex.SCM.checkout/1
    (mix) lib/mix/dep/fetcher.ex:64: Mix.Dep.Fetcher.do_fetch/3
    (mix) lib/mix/dep/converger.ex:174: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:183: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:114: Mix.Dep.Converger.all/7
    (mix) lib/mix/dep/converger.ex:99: Mix.Dep.Converger.all/4
    (mix) lib/mix/dep/converger.ex:50: Mix.Dep.Converger.converge/4
    (mix) lib/mix/dep/fetcher.ex:16: Mix.Dep.Fetcher.all/3

New one on me…

Yes, check this thread on github … https://github.com/kanatohodets/elixir_riak_core_ping/issues/1

1 Like

Please open an issue on https://github.com/hexpm/hex with the commands you ran, the full output, the contents of mix.exs and mix.lock and the output of mix hex.info.

Sure, done: `lib/hex/scm.ex:85: Hex.SCM.checkout/1` error · Issue #247 · hexpm/hex · GitHub

One of the bugs seems to be that riak_core_ng has configured the wrong application name for the basho_poolboy package. The application is set to basho_poolboy but it should be poolyboy.

I have raised the issue with the maintainer of riak_core_ng.

I don’t think it’s a bug in riak_coe_ng because if you compile it with rebar3 it’s work fine. Is it possible a bug in mix that manage rebar3 not correctly?

I’ll try to investigate …

Just to share with you this is a configuration that worked for me:

defmodule Pingring.Mixfile do
  use Mix.Project

  def project do
    [app: :pingring,
     version: "0.0.1",
     elixir: "~> 1.2",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  def application do
    [mod: {Pingring.App, []},
     applications: [:riak_core, :logger]]
  end

  defp deps do
    [
      {:riak_core, git: "https://github.com/project-fifo/riak_core.git", ref: "6c1096a86395aadfe04515a417e3b8c82b82e50c"}
    ]
  end
end

and elixir 1.3.1 and erlang 18.3

Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.3.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

It is most definitely a bug in riak_core_ng or possibly rebar3 by extension. I have verified that the metadata for the riak_core_ng package is incorrect on hex.pm.

It works when using it as git dependency because then the hex metadata is of course not used. It likely also works in rebar3 because it uses the metadata from hex differently.

Ok I understand. I confirm that with rebar3 and erlang 18.3 it’s work, this is the rebar.config if someone is interested:

{erl_opts, [debug_info]}.
{deps, [
  {riak_core, "2.2.5", {pkg, riak_core_ng}}
]}.

{relx, [{release, { rrr, "0.1.0" },
         [rrr,
          sasl]},

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

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

        {extended_start_script, true}]
}.

{profiles, [{prod, [{relx, [{dev_mode, false},
                            {include_erts, true}]}]
            }]
}.

@ericmj Do you open an issue on riak_core? Can you post the link please? I didn’t find the issue on github page :frowning:

I am trying to notify the maintainer of riak_core_ng on IRC. Unfortunately the repository doesn’t have github issues enabled.

1 Like