Unable to compile gleam_otp in a Phoenix app
MattCheely opened this issue · comments
When incorporating gleam_otp into a Phoenix application, the library fails to compile. This isn't a big deal for me, as I have a workaround for now, and it's for a personal side project that currently only runs on my dev machine.
Compile output
➜ mix compile
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Compiling gleam_otp
===> Compiling src/gleam_otp_external.erl failed
src/gleam_otp_external.erl:14: can't find include file "gen/src/gleam@otp@process_Sender.hrl"
src/gleam_otp_external.erl:15: can't find include file "gen/src/gleam@otp@process_Exit.hrl"
src/gleam_otp_external.erl:16: can't find include file "gen/src/gleam@otp@process_PortDown.hrl"
src/gleam_otp_external.erl:17: can't find include file "gen/src/gleam@otp@process_ProcessDown.hrl"
src/gleam_otp_external.erl:18: can't find include file "gen/src/gleam@otp@process_StatusInfo.hrl"
src/gleam_otp_external.erl:119: record process_down undefined
src/gleam_otp_external.erl:122: record port_down undefined
src/gleam_otp_external.erl:125: record exit undefined
src/gleam_otp_external.erl:194: record sender undefined
src/gleam_otp_external.erl:207: record status_info undefined
src/gleam_otp_external.erl:210: variable 'Debug' is unbound
src/gleam_otp_external.erl:210: variable 'Mode' is unbound
src/gleam_otp_external.erl:210: variable 'Parent' is unbound
src/gleam_otp_external.erl:212: variable 'Mode' is unbound
src/gleam_otp_external.erl:212: variable 'Parent' is unbound
src/gleam_otp_external.erl:212: variable 'State' is unbound
src/gleam_otp_external.erl:214: variable 'Mod' is unbound
src/gleam_otp_external.erl:118: Warning: variable 'Pid' is unused
src/gleam_otp_external.erl:118: Warning: variable 'Reason' is unused
src/gleam_otp_external.erl:121: Warning: variable 'Port' is unused
src/gleam_otp_external.erl:121: Warning: variable 'Reason' is unused
src/gleam_otp_external.erl:124: Warning: variable 'Pid' is unused
src/gleam_otp_external.erl:124: Warning: variable 'Reason' is unused
src/gleam_otp_external.erl:192: Warning: variable 'Pid' is unused
src/gleam_otp_external.erl:193: Warning: variable 'Prepare' is unused
** (Mix) Could not compile dependency :gleam_otp, "/home/matt/.mix/rebar3 bare compile --paths /home/matt/projects/beam_ci/_build/dev/lib/*/ebin" command failed. You can recompile this dependency with "mix deps.compile gleam_otp", update it with "mix deps.update gleam_otp" or clean it with "mix deps.clean gleam_otp"
Other Notes
This happens when building with both gleam_compile and mix_gleam
Workaround
I've worked around this by copying gleam.toml
from my local checkout of gleam_otp
into the deps/gleam_otp
folder and running rebar3 compile
there. Once it's compile once, everything works.
It seems that header files are handled differently with mix than with rebar3. The build stuff is currently being rewritten so this should be fixed soon.
This also happens for me when running rebar3 compile
in the test_project
in https://github.com/jeffkreeftmeijer/shine, which is not an Elixir project. It’s resolved if I remove shine
from the project_plugins
in https://github.com/jeffkreeftmeijer/shine/blob/main/test_project/rebar.config#L8.
The workaround worked for me when I copied gleam.toml
into test_project/_build/default/plugins/gleam_otp/
and then ran rebar3 compile
, so I’m not blocked on this either. Thanks for mentioning that! 👍
As we've remake the Mix plugin I'm going to close this as being outdated. If you have further issues please open a new ticket, thank you