OTP27 errors: Failed to load NIF library: 'Error loading shared library /opt/eadm/lib/wx-2.4.3/priv/erl_gl.so

hello every one
i just a erlang newbee, i have a old project use otp 26.2.4, and i wan’t package the docker image as small as possable, use erlang-26.2.4-alpine

in my rebar.config

{relx, [{release, {eadm, "0.1.46"},
[eadm, nova, epgsql, poolboy, lager, sasl, inets, observer, runtime_tools]},
{mode, minimal},
{extended_start_script, true},
{sys_config, "config/sys.config"},
{vm_args, "config/vm.args"},
{overlay, [{mkdir, "priv"},
{copy, "priv/", "priv"}
]}
]}.

in app.src

{included_applications, []},
  {applications,
   [kernel,
    stdlib,
    nova,
    epgsql,
    poolboy,
    lager
   ]},

and docker file

FROM --platform=$BUILDPLATFORM erlang:26.2.4-alpine AS builder

WORKDIR /eadmbuild

COPY . .

RUN apk add --update git
RUN rebar3 as prod release

FROM --platform=$BUILDPLATFORM alpine:3.20

ARG DOCKER_IMAGE_VERSION

ENV \
    DISABLE_IPV6=1 \
    TZ='Asia/Shanghai' \
    LANG='zh_CN.UTF-8'

WORKDIR /opt/eadm

RUN apk add --no-cache ncurses-libs libgcc libstdc++ dumb-init
RUN apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ gosu

COPY --from=builder /eadmbuild/_build/prod/rel/eadm /opt/eadm/
COPY --from=builder /eadmbuild/docker/docker-entrypoint.sh /opt/eadm/docker/docker-entrypoint.sh

RUN ls -l /opt/eadm/lib
RUN chmod +x /opt/eadm/docker/docker-entrypoint.sh

VOLUME /opt/eadm

EXPOSE 8090

LABEL \
      org.label-schema.name="eadm" \
      org.label-schema.description="erlang书写自用管理,提供日常数据统计查询。" \
      org.label-schema.version="${DOCKER_IMAGE_VERSION:-unknown}" \
      org.label-schema.vcs-url="https://github.com/redgreat/eadm" \
      org.label-schema.maintainer="wangcw <rubygreat@msn.com>" \
      org.label-schema.schema-version="1.0"

ENTRYPOINT ["/usr/bin/dumb-init", "-c", "--", "/opt/eadm/docker/docker-entrypoint.sh"]

in

RUN ls -l /opt/eadm/lib

otp26 output without wx library,
but in otp27.2.1, with a wx-2.4.3 dir in this library, but ,yes but it has only inclde dir and ebin dir, when i use then start script

exec /usr/bin/gosu eadm /opt/eadm/bin/eadm foreground

with error

=CRASH REPORT==== 17-Feb-2025::08:32:56.634688 ===
  crasher:
    initial call: application_master:init/3
    pid: <0.1041.0>
    registered_name: []
    exception exit: {{shutdown,
                      {failed_to_start_child,on_load,
                       {on_load_function_failed,gl,
                        {error,
                         {load_failed,
                          "Failed to load NIF library: 'Error loading shared library /opt/eadm/lib/wx-2.4.3/priv/erl_gl.so: No such file or directory'"}}}}},
                     {kernel,start,[normal,[]]}}
      in function  application_master:init/3 (application_master.erl, line 143)
    ancestors: [application_controller,<0.10.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.1052.0>,normal}]
    links: [<0.1051.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 987
    stack_size: 29
    reductions: 92
  neighbours:

what’s wrong with my code or otp bug? help me thanks very much~

otp 27 compile base image erlang:27.2.1-alpine and alpine:3.21

If my application doesn’t have any dependencies on wxWidgets, and if otp26 can run successfully, there wouldn’t be any cascading dependencies either.

You’ve got observer in your relx configuration. observer requires WX. Remove it.

2 Likes

thank you very much,it works!