Oliver

Oliver

How to use preinstalled Erlang on target with releases?

So, I have an elixir application that originally came bundled with its own ERTS (in a release) to be run on a specific server.

The original setup was:

  • build server: Docker image in CI, elixir 1.14.4, OTP 25.3 (x86_x64 architecture, Rocky Linux)
  • included ERTS: Built without some libs (like ncurses not present on target server), but same OTP 25.3
  • target server: it is deployed also on a x86_64 architecture but is Ubuntu LTS

This all worked fine until one day the Docker image (which is used by all our build activities, not just the ones related to elixir) started using GLIBC 2.34 and the target server it is deployed to remained at 2.31. Now the ERTS when deployed could no longer find a compatible GLIBC and our release could no longer be started.

So I wanted to solve this by installing Erlang on the target server and no longer bundling ERTS with the release.
include_erts: false,

We verified that Erlang 25.3.2.2 was installed on target server under /lib/erlang, playing around with the erl shell. It seemed to work fine.

But when we unpack the release and do bin/name_of_release start we get this:

{"init terminating in do_boot",{load_failed,[logger_simple_h,supervisor,proc_lib,lists,logger_backend,logger,logger_server,kernel,filename,gen_server,gen,file_server,erl_parse,file_io_server,file,ets,erl_lint,logger_config,erl_eval,application,code_server,code,application_controller,error_handler,heart,logger_filters,gen_event,error_logger,application_master]}}

Basically the whole Erlang libs are missing. It can find erl from PATH just fine, but somehow none of the required OTP.

I tried supplying OTPROOT and ERL_LIBS on the command line while running the script, but to no avail.

It’s built for V13.2 (on Docker) and on target it has V13.2.2.5, same CPU architecture.

Any ideas what’s going on?

Thank you. :slightly_smiling_face:

Most Liked

LostKobrakai

LostKobrakai

If you’re using docker anyways, why not use a docker image matching your target server to build the release?

Oliver

Oliver

This is the solution my coworker Slawomir Skrzyniarz came up with. It bundles the needed dynamic libraries and patches the executables of the ERTS accordingly to use them. (We’re compiling and deploying on the same architecture, after all.)

We then simply bundle that up in a tarball at the end and unpack it in the right directory on deployment target.

# the base directory here is the path of the release
# as passed to us when registering a function under
# :releases and :steps
mkdir -p lib64
cp -v \
        /usr/lib64/ld-linux-x86-64.so.2 \
        /usr/lib64/libBrokenLocale.so.1 \
        /usr/lib64/libSegFault.so \
        /usr/lib64/libanl.so.1 \
        /usr/lib64/libc.so.6 \
        /usr/lib64/libc_malloc_debug.so.0 \
        /usr/lib64/libdl.so.2 \
        /usr/lib64/libm.so.6 \
        /usr/lib64/libmvec.so.1 \
        /usr/lib64/libnss_compat.so.2 \
        /usr/lib64/libnss_dns.so.2 \
        /usr/lib64/libnss_files.so.2 \
        /usr/lib64/libpthread.so.0 \
        /usr/lib64/libresolv.so.2 \
        /usr/lib64/librt.so.1 \
        /usr/lib64/libthread_db.so.1 \
        /usr/lib64/libtinfo.so.6 \
        /usr/lib64/libutil.so.1 \
        /usr/lib64/libz.so.1 \
        /usr/lib64/libsctp.so.1 \
        /usr/local/gcc-12.2.0/lib64/libgcc_s.so.1 \
        /usr/local/gcc-12.2.0/lib64/libstdc++.so.6 \
        lib64
find bin/ erts-13.2/ -type f -executable -exec patchelf --set-interpreter <absolute installation path on deployment target>/lib64/ld-linux-x86-64.so.2 {} \\; 2>/dev/null
find bin/ erts-13.2/ -type f -executable -exec patchelf --set-rpath <absolute installation path on deployment target>/lib64 {} \\; 2>/dev/null

Where Next?

Popular in Questions Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement