I am porting my OCaml docker containers from Ubuntu to Alpine. And met this error:
<><> Creating initial switch (ocaml-system>=4.02.3) <><><><><><><><><><><><><><>
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed base-bigarray.base
-> installed base-threads.base
-> installed base-unix.base
-> installed ocaml-system.4.07.1
-> installed ocaml-config.1
-> installed ocaml.4.07.1
Done.
# Run eval $(opam env) to update the current shell environment
The following actions will be performed:
- install conf-m4 1 [required by ocamlfind]
- install ocamlfind 1.8.0
===== 2 to install =====
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocamlfind.1.8.0] downloaded from cache at https://opam.ocaml.org/cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed conf-m4.1
[ERROR] The compilation of ocamlfind failed at "/usr/bin/make all".
#=== ERROR while compiling ocamlfind.1.8.0 ====================================#
# context 2.0.1 | linux/x86_64 | ocaml-system.4.07.1 | https://opam.ocaml.org#fa55d97e
# path ~/.opam/default/.opam-switch/build/ocamlfind.1.8.0
# command /usr/bin/make all
# exit-code 2
# env-file ~/.opam/log/ocamlfind-66-2c871f.env
# output-file ~/.opam/log/ocamlfind-66-2c871f.out
### output ###
# [...]
# File "frontend.ml", line 1823, characters 16-29:
# Warning 3: deprecated: Stdlib.String.create
# Use Bytes.create instead.
# ocamlc -I +compiler-libs -o ocamlfind -g findlib.cma unix.cma \
# ocaml_args.cmo frontend.cmo
# ocamlc -I +compiler-libs -opaque -c topfind.mli
# ocamlc -I +compiler-libs -opaque -g -c topfind.ml
# File "topfind.ml", line 55, characters 12-41:
# Error: Unbound module Toploop
# make[1]: *** [Makefile:165: topfind.cmo] Error 2
# make[1]: Leaving directory '/home/myuser/.opam/default/.opam-switch/build/ocamlfind.1.8.0/src/findlib'
# make: *** [Makefile:13: all] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build ocamlfind 1.8.0
+-
+- The following changes have been performed
| - install conf-m4 1
+-
Here is the piece of Dockerfile I used:
FROM alpine:edge
RUN apk add --no-cache make m4 which patch git sudo wget unzip gcc pcre \
pcre libffi ocaml ocaml-ocamldoc opam ocaml-findlib perl python3 \
lz4 lzo p7zip zstd gmp
RUN chmod +s `which bwrap`
RUN addgroup -g 1000 -S myuser && adduser -u 1000 -D -S myuser -G myuser
RUN sed -i.bkp -e \
's/%wheel\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%wheel ALL=NOPASSWD:ALL/g' \
/etc/sudoers
COPY _etc_hosts /etc/hosts
COPY ocamlinit /home/myuser/.ocamlinit
USER myuser
WORKDIR /home/myuser
ENV OCAML_TOPLEVEL_PATH /home/myuser/.opam/default/lib/toplevel
RUN opam init --auto-setup --disable-sandboxing --yes && \
# FIXME: Ugly hack
ln -s /home/myuser/.opam/default/lib/toplevel /home/myuser/.opam/default/lib/topfind && \
eval `opam env` && opam install --yes ocamlfind && \
opam update --yes && export CHECK_IF_PREINSTALLED=false; \
opam install --yes opam-devel
RUN eval `opam env` && \
opam switch create 4.07.1; \
opam switch 4.07.1
RUN eval `opam env` && \
opam install --yes core lwt lwt_log ocaml-migrate-parsetree sexplib dune \
ppx_tools ppx_tools_versioned async_kernel async_unix checkseum
Seems there is an issue (#11453) for that, but is it possible to workaround it somehow?