Fl4m3Ph03n1x

Fl4m3Ph03n1x

Background

I am using elixir 1.9 with erlang 22.0 and I am using the command mix release. However when I try to run my app with _build/dev/rel/andy/bin/my_app start start I get an error:

Error

This is the error I get when trying to run it:

/home/devops/_build/dev/rel/my_app/erts-10.4.3/bin/beam.smp: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory

To fix it I tried running sudo apt-get install libtinfo.so.6 but it doesn’t look like it exists:


Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libtinfo.so.6
E: Couldn't find any package by glob 'libtinfo.so.6'
E: Couldn't find any package by regex 'libtinfo.so.6'

This is my OS operation:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial

How can I fix this?

Showing Posts 1 to 10

NobbZ

NobbZ

You probably build your release on a different setup, one which had libtinfo.so.6 available.

Please build the release on an Ubuntu 16.04.6 and nothing else.


edit

$ curl "https://packages.ubuntu.com/xenial/allpackages?format=txt.gz" | zgrep libtinfo
libtinfo-dev (6.0+20160213-1ubuntu1) developer's library for the low-level terminfo library
libtinfo5 (6.0+20160213-1ubuntu1) shared low-level terminfo library for terminal handling
libtinfo5-dbg (6.0+20160213-1ubuntu1) debugging/profiling library for the low-level terminfo library

For 16.04 only libtinfo5 is available as it seems.

It contains the following files (Ubuntu – Error):

  • /lib/x86_64-linux-gnu/libtinfo.so.5
  • /lib/x86_64-linux-gnu/libtinfo.so.5.9
  • /usr/lib/x86_64-linux-gnu/libtic.so.5
  • /usr/lib/x86_64-linux-gnu/libtic.so.5.9
  • /usr/share/doc/libtinfo5/TODO.Debian
  • /usr/share/doc/libtinfo5/changelog.Debian.gz
  • /usr/share/doc/libtinfo5/copyright
baruch

baruch

I have the same error when trying to run an app that I built in Docker on the Elixir 1.9.1 image, my Dockerfile is:

FROM elixir:1.9.1 AS builder
WORKDIR /app/monolith
COPY . .
ENV MIX_ENV=prod
WORKDIR /app/monolith/apps/server
RUN mix local.hex --force; mix local.rebar --force
RUN mix deps.get
RUN mix compile 

FROM builder AS release 
WORKDIR /app/monolith/apps/server
ENV MIX_ENV=prod
RUN mix release 
ENTRYPOINT ["/app/monolith/_build/prod/rel/server/bin/server"]
NobbZ

NobbZ

Do you see that error when you start or when you build that docker, or are you extracting the built release and run it elsewhere?

baruch

baruch

I believe this error was due to my copying build/release artifacts into my image. I added _build to .dockerignore and now the app starts.

To answer your question, the crash occurred whether running in the same container as the build or copying the release to a fresh one.

NobbZ

NobbZ

Yeah, _build and deps from your host should never slip into the container, or vice versa…

Also there are some other culprits with your dockerfile. Even the final stage still contains all the temporary artifacts and source code. This increases the size of the resulting image unnecessarily. You should try to properly use the multi-stage you already started with.

baruch

baruch

Yup, thank you. I got it working with the following Dockerfile:

FROM elixir:1.9.1 AS builder
WORKDIR /app/monolith
COPY . .
WORKDIR /app/ 
ENV MIX_ENV=dev
WORKDIR /app/monolith/apps/server
RUN mix local.hex --force; mix local.rebar --force
RUN mix deps.get
RUN mix compile 

FROM builder AS release 
WORKDIR /app/monolith/apps/server
ENV MIX_ENV=dev
RUN mix release 
ENTRYPOINT ["/app/monolith/_build/dev/rel/server/bin/server"]

FROM base AS runner
COPY --from=release /app/monolith/_build/dev/rel/server/ /app
ENTRYPOINT [ "/app/bin/server" ]

and .dockerignore:

.git
_build

Still needs a bit of work, in particular to allow prod builds, but its a start.

(I take your point about not copying in the deps, but that is giving me issues with a timeout from hex.pm when fetching tzdata.)

NobbZ

NobbZ

Please also add deps to your .dockerignoe. Some packages create artifacts in there :frowning:

Also, I can’t see where you define base, but you reference it. Just from looking at it, this wont actually work.

baruch

baruch

Thanks. I will add deps, good to know how important that is.

The base image is stored in my internal repository, and is just Ubuntu with a couple of basic changes.

flp

flp

Just as addition here: I got this error because the build was running on Ubuntu 18.10 but my prod is running on Ubuntu 18.04. So I migrated my pipeline back to 18.04 and everything is fine again

Manzanit0

Manzanit0

Just for the record, I came across this yesterday, same issue, etc. and this is the final working Dockerfile I came up with, in case anybody finds it useful.

FROM elixir:1.10.3 AS app_builder

ENV MIX_ENV=prod \
    LANG=C.UTF-8

# Build local package repository
RUN mix local.hex --force && \
    mix local.rebar --force

RUN mkdir /app
WORKDIR /app

# Compile dependencies
COPY mix.exs .
COPY mix.lock .
RUN mix deps.get && mix deps.compile

# Let's make sure we have node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
    apt-get install -y nodejs

# Compile assets
COPY assets ./assets
RUN npm install --prefix ./assets && \
    npm run deploy --prefix ./assets

# Now, let's go with the actual elixir code. The order matters: if we only
# change elixir code, all the above layers will be cached ~ less image build time.
COPY config ./config
COPY lib ./lib
COPY priv ./priv

# Final build step: digest static assets and generate the release
RUN mix phx.digest && mix release

FROM debian:buster-slim AS app

ENV LANG=C.UTF-8

RUN apt-get update && apt-get install -y openssl

RUN useradd --create-home app
WORKDIR /home/app
COPY --from=app_builder /app/_build .
RUN chown -R app: ./prod
USER app

CMD ["./prod/rel/cookbook/bin/cookbook", "start"]
— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews