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

From: Pat Maddox <>
Date: Thu, 05 May 2022 08:41:15 UTC
On 4 May 2022, at 23:48, Pat Maddox wrote:

> On 4 May 2022, at 7:16, Dave Cottlehuber wrote:
>> On Wed, 4 May 2022, at 11:16, Pat Maddox wrote:
>>> 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.

I have found the culprit.

mix release sets an ERTS_BIN env var in the startup script:

However, the port replaces it:

So where mix release produces the following lines in 


The port changes them to:


Removing the post-patch target solves the problem: I can run `ex_ample 
start_iex` with no erlang or elixir installed. It uses the erts bundled 
in /usr/local/libexec/ex_ample/erts-12.3.1/.

Removing post-patch however breaks the current lang/elixir-devel build, 
because now erl is not in the path.

We have two scenarios:

1. lang/erlang-runtime24 is installed (and not lang/erlang) - this needs 
the post-patch
2. lang/erlang is installed - this does not need the post-patch, and in 
fact the post-patch breaks the bundled erts in mix releases.

How should we go about solving this? One simple idea is to call `which 
erl` to see if it exists, and if so then we can skip the post-patch.

Another idea is to add a PROVIDES_ERL variable, and make 
lang/erlang-runtime24 add erl to /usr/local/bin, and conflict with 
lang/erlang. If you want full erlang on your system, you could set 

Perhaps it’s even simpler. Instead of:

BUILD_DEPENDS=	erlang-runtime${ERLANG_VER}>0:lang/erlang-runtime${ERLANG_VER}
RUN_DEPENDS=	erlang-runtime${ERLANG_VER}>0:lang/erlang-runtime${ERLANG_VER}

It could be:

DEPENDS=	erl:lang/erlang-runtime${ERLANG_VER}

and again lang/erlang-runtime24 would install /usr/local/bin/erl.

I am quite new to FreeBSD ports and makefiles in general though, so am 
interested in a good approach to this.