From owner-freebsd-erlang@freebsd.org  Thu May 30 12:50:18 2019
Return-Path: <owner-freebsd-erlang@freebsd.org>
Delivered-To: freebsd-erlang@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 51BB915C14DC
 for <freebsd-erlang@mailman.ysv.freebsd.org>;
 Thu, 30 May 2019 12:50:18 +0000 (UTC)
 (envelope-from dch@skunkwerks.at)
Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org
 [IPv6:2001:1900:2254:206a::50:5])
 by mx1.freebsd.org (Postfix) with ESMTP id A1C9A872C4
 for <freebsd-erlang@freebsd.org>; Thu, 30 May 2019 12:50:17 +0000 (UTC)
 (envelope-from dch@skunkwerks.at)
Received: by mailman.ysv.freebsd.org (Postfix)
 id 6225115C14DB; Thu, 30 May 2019 12:50:17 +0000 (UTC)
Delivered-To: erlang@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2115615C14DA
 for <erlang@mailman.ysv.freebsd.org>; Thu, 30 May 2019 12:50:17 +0000 (UTC)
 (envelope-from dch@skunkwerks.at)
Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com
 [64.147.123.19])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id A6DE7872BC
 for <erlang@freebsd.org>; Thu, 30 May 2019 12:50:16 +0000 (UTC)
 (envelope-from dch@skunkwerks.at)
Received: from compute7.internal (compute7.nyi.internal [10.202.2.47])
 by mailout.west.internal (Postfix) with ESMTP id E3187472;
 Thu, 30 May 2019 08:50:07 -0400 (EDT)
Received: from imap6 ([10.202.2.56])
 by compute7.internal (MEProxy); Thu, 30 May 2019 08:50:08 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skunkwerks.at;
 h=mime-version:message-id:in-reply-to:references:date:from:to
 :subject:content-type:content-transfer-encoding; s=fm2; bh=fSM2h
 g0RSwTko0FL4J+PSYzopvcPWsRppX8VLr5h3RE=; b=pl9Fw7Vv134m5ETyCZRoQ
 qwVcaXVNaQZ+E0QbifMj87w8ZQ/AFJlPxmZCZvPTdgnOkAag6L92EymuIK1qBnEA
 UE71CZX1JEcnVsOCG3eHBJw+7WrKlfIBkATuP6lJkX1eYVI0wnDKbDa5NtZq9f2d
 CUKzm4UclLgHlsZdSt1n53VdR/aOSJc+YYi45iVbcDFKZ/xYrROPuOA8J4nJvWeo
 OZfWGE2exKsgZokI7x2SRMxMHWxG34rslk1M/oPb0ZVwKzvSEqLs1qWJoDUaI3W8
 sxQ23S6nR1wUBAt0NulgrnTr3nLP82w2Uwz7y9WEB0KmT6k9gAifffkKzmWPW4t6
 g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-transfer-encoding:content-type
 :date:from:in-reply-to:message-id:mime-version:references
 :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm2; bh=fSM2hg0RSwTko0FL4J+PSYzopvcPWsRppX8VLr5h3
 RE=; b=IjD+3DZoTu3btMdxIpwoJF5bne56+62JfY9Z5v1A35jV8Cv9ZQtWJJDsg
 Om3+ZHd2yHJnWp8BmgQ2WbG8BOWteMgqLTn7ElKqWnfKIztbZWzItDeH3mSKqQB1
 GAOIYodjyP2uEEaDpjIoeDjAs3hT5W+pHMqdkTNcjulMYNSpacJ3+gtm3oOZMbkN
 wff3VAlMv4VJWom4b4CPneuttaWW+aHiM69i8knRUFVEJiI6+j7XE8CByJUfQTak
 ihU2YtXaxfYUZ7aVyyrj+ZfaispaDbV4EcwPjS931HGKR+AzL1vTt6EyPwd5yI0L
 Bj/F0TuoPnaUZnST76I3XQFve9TSg==
X-ME-Sender: <xms:f9HvXEnjZjZnrxjO8cApY2lVMkujIq5HEBcW-t60LLN8K0XSdW6Dig>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddvledgheeiucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth
 hqredtreerjeenucfhrhhomhepfdffrghvvgcuvehothhtlhgvhhhusggvrhdfuceouggt
 hhesshhkuhhnkhifvghrkhhsrdgrtheqnecurfgrrhgrmhepmhgrihhlfhhrohhmpegutg
 hhsehskhhunhhkfigvrhhkshdrrghtnecuvehluhhsthgvrhfuihiivgeptd
X-ME-Proxy: <xmx:f9HvXPipUQT6g06P74N69_k0ti3SFqe_LCVjEqkhnCMe8XDwImHeQQ>
 <xmx:f9HvXGTMVbA2jvETd8NKe2SsV2NPvITAh0u9Wkm8aYLPl2HkIk326g>
 <xmx:f9HvXA2tWzsuGSOCXoJ-9ezZeEG95UESwSXDwwzW_E02yLqS8KCqLg>
 <xmx:f9HvXH7kjqH8aa1BIhrRGpZQxtOzub458LS3doom85DZZoms12ZQ1A>
Received: by mailuser.nyi.internal (Postfix, from userid 501)
 id 038531400A0; Thu, 30 May 2019 08:50:07 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.1.6-555-g49357e1-fmstable-20190528v2
Mime-Version: 1.0
Message-Id: <36da7161-b304-4456-8027-d12eba2ac217@www.fastmail.com>
In-Reply-To: <4259DD93-00E2-4EB6-A1C3-DC4CBCEDD34C@getsomewhere.net>
References: <4259DD93-00E2-4EB6-A1C3-DC4CBCEDD34C@getsomewhere.net>
Date: Thu, 30 May 2019 12:50:06 +0000
From: "Dave Cottlehuber" <dch@skunkwerks.at>
To: "Joe Love" <joe@getsomewhere.net>, erlang@freebsd.org
Subject: Re: Deploying program on erlang runtime 21
Content-Type: text/plain;charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Rspamd-Queue-Id: A6DE7872BC
X-Spamd-Bar: ------
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-6.99 / 15.00];
 NEURAL_HAM_MEDIUM(-1.00)[-1.000,0];
 NEURAL_HAM_SHORT(-0.99)[-0.986,0]; REPLY(-4.00)[];
 NEURAL_HAM_LONG(-1.00)[-1.000,0]
X-BeenThere: freebsd-erlang@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Support of Erlang-related ports <freebsd-erlang.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-erlang>, 
 <mailto:freebsd-erlang-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-erlang/>
List-Post: <mailto:freebsd-erlang@freebsd.org>
List-Help: <mailto:freebsd-erlang-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-erlang>,
 <mailto:freebsd-erlang-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 30 May 2019 12:50:18 -0000

On Wed, 29 May 2019, at 20:31, Joe Love wrote:
> Hi,
>=20
> I=E2=80=99ve been trying to wrap my head around creating my Elixir-bas=
ed=20
> projects on my client workstations (which are not freebsd) and=20
> deploying them to a FreeBSD server using the erlang-runtime-21 package=
.
>=20
> I think I=E2=80=99m a bit lost somewhere on it, and am hoping to get s=
ome guidance here.
>=20
> I=E2=80=99ve created my project on my mac.  I=E2=80=99ve added Distill=
ery (per many=20
> suggestions & guides).  If I understand everything correctly, I can=E2=
=80=99t=20
> include ERTS, as that=E2=80=99s the part which is compiled based on th=
e host=20
> OS.  Therefore, I modified my Distillery config to not include ERTS in=
=20
> the production build, and then ran `mix release --env=3Dprod`.
>=20
> I uploaded the resulting _build/dev/rel/myproject to the FreeBSD serve=
r=20
> which has erlang-runtime-21 on it.
> I set my path to include /usr/local/lib/erlang21/bin, added=20
> ERTS_LIB_DIR =3D /usr/local/lib/erlang21/erts-10.3 and tried to run it=
. =20
> Apparently I have erts-10.1 on my machine and the server had erts-10.3=
,=20
> so it seems that that also needs to match.
>=20
> So, given all of this, I remember being told that while the lang/erlan=
g=20
> port was older, that I could always use the runtime ports, and things=20=

> would work.  Can someone fill me in on how they're supposed to work? =20=

> It seems like things are more intricate regarding running beam-vm-base=
d=20
> programs on a different machine than that you=E2=80=99re building it o=
n.
>=20
> Thanks,
> -Joe

Hey Joe,

welcome. I deploy to FreeBSD with Elixir & distillery 2.0 without any is=
sues.=20
The simple fix is to move off OSX to FreeBSD like I did and then this pr=
oblem
goes away ;-).

TLDR: build your releases on the same OS+package as your deploy target.

If you unpack the .tar.gz that distillery creates, you'll see inside a .=
/releases/
folder. the RELEASES and *.rel and start_erl.data all specify explicit v=
ersions
of runtime and related libraries. If your Mac-based OTP release is *exac=
tly*
the same as the FreeBSD one, *and* you have no NIFs, then it's possible
to get this working.

IMHO getting cross-compilation etc sorted isn't worth it when you can
build in a jail anyway. I then create FreeBSD packages from the distille=
ry
release, and simply pkg-install those.

I'll write this up and post a link to it tomorrow on how to do this, it'=
s
too long to fit in an email.

details:

1. always build releases on the same OS+arch+BEAM+packages as you
intend to deploy to. Cross-building is possible but surprisingly tricky.=

If the patch versions are different, stuff may not start.

erts (Erlang RunTime System) has different patch levels and point releas=
es.
The OTP 21 runtime on your Mac may not be the same one you're deploying
to.

The FreeBSD ones have just this week been updated and moved to a much
easier-to-update system (thanks olgeni@ ) so we should be staying pretty=

up to date with official releases now. We have OTP21,22 and Elixir 1.8.2=


Right now, that's 21.3.8.2 which has different modules from the original=

OTP 21.0 shipped months ago -
asn1, crypto, kernel, ssl, stdlib, & more have all evolved. Your mac
built release probably won't have the same modules on it, and the releas=
e
is *very* specific about what it requires.

2. if you have NIF modules (native C code) then this definitely won't wo=
rk
as the linked libraries aren't remotely compatible.

3. Every time the lang/erlang-* port is updated, you'll need to rebuild =
your
application (if you're not including erts).
=20
A+
Dave