Error installing ocamlfind and dune using opam

I’m getting the following error when installing core using opam install core in openSUSE Leap 15.2:

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of dune failed at
        "/home/isaac/.opam/opam-init/hooks/sandbox.sh build ocaml bootstrap.ml -j
        7".
[ERROR] The compilation of ocamlfind failed at
        "/home/isaac/.opam/opam-init/hooks/sandbox.sh build make all".

#=== ERROR while compiling ocamlfind.1.9.1 ====================================#
# context     2.0.8 | linux/x86_64 | ocaml-system.4.12.0 | https://opam.ocaml.org#3e991263
# path        ~/.opam/default/.opam-switch/build/ocamlfind.1.9.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build make all
# exit-code   2
# env-file    ~/.opam/log/ocamlfind-10862-5e06f5.env
# output-file ~/.opam/log/ocamlfind-10862-5e06f5.out
### output ###
# [...]
# Use Bytes.create/BytesLabels.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 47, characters 4-25:
# 47 |     Topdirs.dir_directory d;
#          ^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound module Topdirs
# make[1]: *** [Makefile:165: topfind.cmo] Error 2
# make[1]: Leaving directory '/home/isaac/.opam/default/.opam-switch/build/ocamlfind.1.9.1/src/findlib'
# make: *** [Makefile:14: all] Error 2


#=== ERROR while compiling dune.2.9.0 =========================================#
# context     2.0.8 | linux/x86_64 | ocaml-system.4.12.0 | https://opam.ocaml.org#3e991263
# path        ~/.opam/default/.opam-switch/build/dune.2.9.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml bootstrap.ml -j 7
# exit-code   2
# env-file    ~/.opam/log/dune-10862-c291cc.env
# output-file ~/.opam/log/dune-10862-c291cc.out
### output ###
# ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot unix.cma boot/libs.ml boot/duneboot.ml
# gcc-7: error trying to exec 'cc1': execvp: No such file or directory
# File "boot/duneboot.ml", line 1:
# Error: Error while building custom runtime system



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build dune      2.9.0
│ λ build ocamlfind 1.9.1
└─ 
╶─ No changes have been performed

GCC is installed and I checked that the cc1 file exists, how can I fix this?

This is a little bit strange but I see you are on a system switch which is always a bit more brittle.

Here are things that could go wrong:

  1. Your system compiler doesn’t install compiler libs. Can you check that ls $(ocamlc -where)/compiler-libs/topdir.* returns result ?
  2. Maybe the opam sandboxing doesn’t allow you to access ocamlc -where/compiler-lib ? I’m not up-to-date with the details of the opam sandboxing stuff, but I bet the opam devs got that right, so it seems unlikely.

If none of this brings any answer maybe the best is to use a non-system switch (something like opam switch create 4.12.0 && opam install core).

Actually I missed that. I really suspect some kind of sandboxing issue, it seems that some stuff cannot be found in the PATH.

Thanks for your answer. The compiler-libs folder does not exist.
I tried a switch using opam switch create ocaml-system.4.12.0 && opam install core but the error still persists.

Is it the same errors ?

Yes, the exact same errors.

Ah but you likely created a system switch… this should be ocaml.4.12.0 or ocaml-base-compiler.4.12.0 maybe, checkout opam switch list.

1 Like

I created a switch correctly and it worked, thanks for your help.

1 Like