Ubuntu exec: .../erlexec: not found

I’ve built a release in docker with the help of :mix_docker, then copied the tarfile to the server running ubuntu 16.04, and then tried to bin/backend start the app (which is called “backend”). And I got this

> bin/backend start
/home/idiot/backend/erts-9.1.3/bin/erl: 13: exec: /home/idiot/backend/erts-9.1.3/bin/erlexec: not found

although the file is there

> file /home/idiot/backend/erts-9.1.3/bin/erlexec
/home/idiot/backend/erts-9.1.3/bin/erlexec: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped

I wonder what the problem is.

Am I missing the interpreter? No, it seems to exist.

> /lib/ld-musl-x86_64.so.1
musl libc
Version 1.1.9
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname [args]

I’ve changed the shell to be used for erts-9.1.3/bin/erl to bash:

- #!/bin/sh
+ #!/bin/bash
set -e

SCRIPT_DIR=`dirname $0`
ROOTDIR=`cd $SCRIPT_DIR/../../ && pwd`
BINDIR=$ROOTDIR/erts-9.1.3/bin
EMU=beam
PROGNAME=`echo $0 | sed 's/.*\\///'`
export EMU
export ROOTDIR
export BINDIR
export PROGNAME
exec "$BINDIR/erlexec" ${1+"$@"}

and got this

> bin/backend start

Error loading shared library libz.so.1: No such file or directory (needed by /home/idiot/backend/erts-9.1.3/bin/beam.smp)
Error loading shared library libncursesw.so.6: No such file or directory (needed by /home/idiot/backend/erts-9.1.3/bin/beam.smp)
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflate: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflate: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: tputs: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: crc32: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: crc32_combine: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateReset: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: tgetflag: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: tgetent: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateInit2_: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: tgetnum: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateParams: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: adler32_combine: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateInit_: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateEnd: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateSetDictionary: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: adler32: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateGetDictionary: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateEnd: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: pthread_setname_np: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateInit_: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateInit2_: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: tgetstr: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: inflateReset: symbol not found
Error relocating /home/idiot/backend/erts-9.1.3/bin/beam.smp: deflateSetDictionary: symbol not found
1 Like

It seems you are missing libz and ncurses. The other errors seem to be related to the missing libz on a first glance.

But they also exist

> locate libncurses
/lib/x86_64-linux-gnu/libncurses.so.5
/lib/x86_64-linux-gnu/libncurses.so.5.9
/lib/x86_64-linux-gnu/libncursesw.so.5
/lib/x86_64-linux-gnu/libncursesw.so.5.9
...
>  locate libncursesw
/lib/x86_64-linux-gnu/libncursesw.so.5
/lib/x86_64-linux-gnu/libncursesw.so.5.9
/usr/share/doc/libncursesw5
/var/lib/dpkg/info/libncursesw5:amd64.list
/var/lib/dpkg/info/libncursesw5:amd64.md5sums
/var/lib/dpkg/info/libncursesw5:amd64.shlibs
/var/lib/dpkg/info/libncursesw5:amd64.symbols
/var/lib/dpkg/info/libncursesw5:amd64.triggers

Also found this https://askubuntu.com/questions/771047/erlang-error-while-loading-shared-libraries-libncursesw-so-6

You need to install ncursesw6.

Also please check for the availability of libz.

> find /usr/lib -name libz.so
/usr/lib/x86_64-linux-gnu/libz.so

And I can’t find ncursesw6 with apt.

Then you need to build your release on a system that has ncursesw5.

Also you’ll probably need to build it on a system that uses glibc instead of libmusl.

Do not build releases on different OS than you want to run them.

3 Likes

The issue here is that the release was built in Alpine and is being deployed to Ubuntu, and includes ERTS - that won’t work. You need to either not include ERTS, or build in an Ubuntu container/VM/etc. I would recommend the latter, since if you have NIFs, they may also be sensitive to the difference. Hopefully in the future we’ll have a way to build “linux generic” releases, but that is not the case today.

4 Likes

Yeah, I though for some reason that any linux distro would do. Before that I was using a freebsd (building the release with vagrant), but decided to try building with docker for linux …