basho / riak-erlang-client

The Riak client for Erlang.
Apache License 2.0
311 stars 189 forks source link

riak-erlang-client protobuf compilation problem in Elixir/Mix projects #409

Closed javobalazs closed 2 years ago

javobalazs commented 2 years ago

If riak-erlang-client is a dependency in an Elixir project, riak_pb won't compile properly. The protobuf to erlang compilation does take place but the resulting files are not get compiled. Setup:

defmodule Whatever.MixProject do
  use Mix.Project

  # ...

  defp deps do
    [
      {:riakc, git: "https://github.com/basho/riak-erlang-client.git", tag: "3.0.8"},
      # ...
    ]
  end
end
uname -a
Linux xxxxx 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
iex
Erlang/OTP 24 [erts-12.3.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Interactive Elixir (1.13.0) - press Ctrl+C to exit (type h() ENTER for help)

After a mix compile I get these files:

_build/dev/lib/riak_pb/src/riak_dt_pb.erl
_build/dev/lib/riak_pb/src/riak_kv_pb.erl
_build/dev/lib/riak_pb/src/riak_pb.erl
_build/dev/lib/riak_pb/src/riak_search_pb.erl
_build/dev/lib/riak_pb/src/riak_ts_pb.erl
_build/dev/lib/riak_pb/src/riak_yokozuna_pb.erl

But these are not compiled further to beam. As an ugly workaround, I copied these files, together with the corresponding include files, and gpb.hrl to the src directory in my project, and now it works.

UPDATE: included OS info

martinsumner commented 2 years ago

Sorry, I don't have any experience of Elixir/Mix, so wouldn't know how to help with this. Maybe someone else will?

@Bob-The-Marauder is this something someone in TI Tokyo could look at?

javobalazs commented 2 years ago

Update: it's working on a different machine and slightly different configuration:

uname -a
FreeBSD xxxxx 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64
iex
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit] [dtrace]
Interactive Elixir (1.12.3) - press Ctrl+C to exit (type h() ENTER for help)

I guess this is the elixir version that counts here.

javobalazs commented 2 years ago

Update: Working on DragonFlyBSD too. Erlang/Elixir is the same as in FreeBSD.

uname -a
DragonFly xxxxxx 6.2-RELEASE DragonFly v6.2.2.3.gca806c-RELEASE #7: Fri Jul 29 13:23:49 CEST 2022     root@xxxxxx:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64
iex
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:no-native-stack]
Interactive Elixir (1.12.3) - press Ctrl+C to exit (type h() ENTER for help)
javobalazs commented 2 years ago

Okay, one last observation, and I finish my "running amok" here. The mix-provided rebar does count, regardless of the fact that rebar3 is packaged with the projects. Apparently, mix is using its own rebar anyway. When it was outdated, compilation failed right away. I updated it with this:

mix local.rebar

After this, compilation was successful, and on the BSDs, the project actually worked. On the Linux, it failed with an exception for the missing modules, regardless of the fact that the compilation returned no error. Surprisingly, the local rebar version is the same on all the three:

/home/xxxxx/.mix/rebar3 --version
rebar 3.15.2 on Erlang/OTP 24 Erts 12.2.1
javobalazs commented 2 years ago

It turned out to be a problem in Elixir 1.13 and higher. https://github.com/elixir-lang/elixir/issues/12108