Cannot compile an Erlang dependency in an Elixir project

Hi,
I am using the following versions:
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Elixir 1.18.4 (compiled with Erlang/OTP 27)

I am compiling an Identicon project based on the one by Stephen Grider.
In this project, I use the following dependency:
{:egd24, “~> 0.10”}

Unfortunately, when compiling this dependency, I get a compile error:

  mix deps.compile egd24
===> Analyzing applications...
===> Compiling string_compat
===> Compiling bbmustache
===> Compiling _build/default/plugins/bbmustache/src/bbmustache.erl failed
     ââ _build/default/plugins/bbmustache/src/bbmustache.erl:
     â
 622 â  -spec check_data_type(data() | term()) -> boolean() | maybe.
     â                                                        â°ââ syntax error before: 'maybe'

     ââ _build/default/plugins/bbmustache/src/bbmustache.erl:
     â
 624 â  check_data_type([])                               -> maybe;
     â                                                            â°ââ syntax error before: ';'


     ââ _build/default/plugins/bbmustache/src/bbmustache.erl:
     â
 181 â      case check_data_type(Data) of
     â           â°ââ function check_data_type/1 undefined

     ââ _build/default/plugins/bbmustache/src/bbmustache.erl:
     â
 207 â      case check_data_type(Value) of
     â           â°ââ function check_data_type/1 undefined

     ââ _build/default/plugins/bbmustache/src/bbmustache.erl:
     â
 592 â      case check_data_type(Data) =:= true andalso find_data(convert_keytype(Key, State), Data) of
     â           â°ââ function check_data_type/1 undefined

Any help appreciated…
Thanks, :slight_smile:

1 Like

maybe was introduced as an Erlang feature in OTP 27.

You can disable it partially using a couple different methods:

I suspect there’s a way to pass the required options for just one dependency when building with mix deps, but I don’t see a good example of it.

The easiest approach would be to copy bbmustache locally and add -feature(maybe_expr, disable) to the top of bbmustache.erl.

1 Like

Hi al2o3cr,
Your suggestion worked!!
In file ...deps/egd/_build/default/plugins/bbmustache/src/bbmustache.erl, I added -feature(maybe_expr, disable). after -module(bbmustache). and was then able to successfully compile the egd depedency.
Many, many thanks :slight_smile:

Hi,

I found a better solution thanks to the advise of Hinagiku Soranoba (the publisher of bbmustache).

I updated file rebar.config of the egd app to use the latest version of rebar3_appup_pluginlike so:

%% -*- erlang -*-
% {plugins, [rebar3_appup_plugin]}.
{plugins, [{rebar3_appup_plugin, "2.4.8"}]}.

{provider_hooks, [{post, [{compile, {appup, compile}},
                          {clean, {appup, clean}}]}
                 ]}.

{otpdoc_opts, [{edoc_modules, [egd]}]}.

%% vim: ft=erlang

1 Like