Re: package mix release works, port doesn't? (and neither is self-contained)

From: Dave Cottlehuber <dch_at_skunkwerks.at>
Date: Wed, 04 May 2022 14:16:53 UTC
On Wed, 4 May 2022, at 11:16, Pat Maddox wrote:
> On 4 May 2022, at 4:06, Pat Maddox wrote:
>
>> So my questions are:
>>
>> 1. What is going on with poudriere that’s different, where the 
>> package runs fine but the built port crashes?

probably PATH yielding different erlang/elixir versions; these will
have *slightly* different version numbers of OTP libraries, and
the system then can't start up as the located ERTS has differing
versions of the expected libraries. Hard to tell from those errors.

>> 2. How do I fix it?

- ensure your path is clean ;-)
- do your prod release with erts included
- prepend /usr/local/lib/$APP/erts-$VERSION/bin

>> 3. Why do the package and port require an erlang runtime to run, if 
>> I’m using mix release?
>
> Of course after being stuck on this for a couple hours, I answered the 
> first two questions just a few minutes after posting: the 
> erlang-runtime24 dependency was getting installed via normal FreeBSD 
> package source, rather than my poudriere built version. So it was a 
> version mismatch between the build dependency and run dependency.
>
> I still don’t understand why I need an erlang runtime at all though, 
> after the mix release has been built.
>
> Pat

you don't; whether erts is bundled in the release is defined in your
mix release config. I'm assuming your ExAmple app picks up whatever
the default is, see the hello app for an appropriate example.

https://hexdocs.pm/mix/Mix.Tasks.Release.html
& 
https://github.com/skunkwerks/hello/blob/master/rel/config.exs#L33

I've tried both approaches in the past, and now I always bundle
erts within the application.

You do need to run the epmd daemon somewhere, this is easily
enough done via including lang/erlang as a package dependency,
or via your CI/CD deployment tools, and starting the epmd service
that is provided on FreeBSD.

I suggest taking a close look through build.sh, app.sh and the rc.d
wrapper in the hello app above, each of the lines there deals
with all these nasty little issues.

A+
Dave