1

I am trying to install some Ocaml packages but for some reason I am having some errors with installing dune, ocamlbuild, and ocamlfind. By running sudo opam install ocamlfind ounit utop dune qcheck, the following error came up:

[ERROR] The compilation of dune.3.4.1 failed at "ocaml bootstrap.ml -j 7".
[ERROR] The compilation of ocamlbuild.0.14.1 failed at "make check-if-preinstalled all opam-install".
[ERROR] The compilation of ocamlfind.1.9.5 failed at "make opt".

#=== ERROR while compiling ocamlfind.1.9.5 ====================================#
# context     2.1.3 | macos/arm64 | ocaml.4.12.0 | https://opam.ocaml.org#2e9465d0
# path        ~/.opam/default/.opam-switch/build/ocamlfind.1.9.5
# command     ~/.opam/opam-init/hooks/sandbox.sh build make opt
# exit-code   2
# env-file    ~/.opam/log/ocamlfind-21232-a598ab.env
# output-file ~/.opam/log/ocamlfind-21232-a598ab.out
### output ###
# for p in findlib; do ( cd src/$p; /Library/Developer/CommandLineTools/usr/bin/make opt ) || exit; done
# ocamlopt -I +compiler-libs -g -opaque  -I +unix -I +dynlink -c findlib_config.ml
# clang: error: unable to make temporary file: Operation not permitted
# File "findlib_config.ml", line 1:
# Error: Assembler error, input left in file /tmp/camlasm9d6939.s
# make[1]: *** [findlib_config.cmx] Error 2
# make: *** [opt] Error 2


#=== ERROR while compiling ocamlbuild.0.14.1 ==================================#
# context     2.1.3 | macos/arm64 | ocaml.4.12.0 | https://opam.ocaml.org#2e9465d0
# path        ~/.opam/default/.opam-switch/build/ocamlbuild.0.14.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build make check-if-preinstalled all opam-install
# exit-code   2
# env-file    ~/.opam/log/ocamlbuild-21232-d41248.env
# output-file ~/.opam/log/ocamlbuild-21232-d41248.out
### output ###
# [...]
# ocamlc.opt -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/ocamlbuild_executor.ml
# ocamlc.opt -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/ocamlbuild_unix_plugin.mli
# ocamlc.opt -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/ocamlbuild_unix_plugin.ml
# ocamlc.opt -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/ocamlbuild.mli
# ocamlc.opt -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/ocamlbuild.ml
# ocamlc.opt -I +unix -I src -o ocamlbuild.byte unix.cma src/ocamlbuild_pack.cmo src/ocamlbuild_plugin.cmo src/ocamlbuild_executor.cmo src/ocamlbuild_unix_plugin.cmo src/ocamlbuild.cmo
# ocamlc.opt -a -o src/ocamlbuildlib.cma src/ocamlbuild_pack.cmo src/ocamlbuild_plugin.cmo src/ocamlbuild_executor.cmo src/ocamlbuild_unix_plugin.cmo
# ocamlopt.opt -for-pack Ocamlbuild_pack -w +L -w +R -w +Z -I src -I +unix -safe-string -bin-annot -strict-sequence -c src/const.ml
# clang: error: unable to make temporary file: Operation not permitted
# File "src/const.ml", line 1:
# Error: Assembler error, input left in file /tmp/camlasmb8862d.s
# make: *** [src/const.cmx] Error 2


#=== ERROR while compiling dune.3.4.1 =========================================#
# context     2.1.3 | macos/arm64 | ocaml.4.12.0 | https://opam.ocaml.org#2e9465d0
# path        ~/.opam/default/.opam-switch/build/dune.3.4.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml bootstrap.ml -j 7
# exit-code   2
# env-file    ~/.opam/log/dune-21232-574465.env
# output-file ~/.opam/log/dune-21232-574465.out
### output ###
# ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot unix.cma boot/libs.ml boot/duneboot.ml
# clang: error: unable to make temporary file: Operation not permitted
# File "boot/duneboot.ml", line 1:
# Error: Error while building custom runtime system



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>   
┌─ The following actions failed
│ λ build dune       3.4.1
│ λ build ocamlbuild 0.14.1
│ λ build ocamlfind  1.9.5
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install seq base
└─ 
# Run eval $(opam env) to update the current shell environment

As a pretext, I was just setting up my dev environment by installing:

  • latest homebrew
  • ruby 3.1.2p20 (arm64-darwin20)
  • ocaml 4.12
  • opam 2.1.3
  • with opam packages ocamlfind, ounit, utop, dune, qcheck

If it is of any help I have also initialized the OCaml package manager by running opam init and allowing the manager to edit my ~/.zshrc to which I've followed with by running source ~/.zshrc. Note that all installation are done with/without sudo or arch -arm64 flags (to which I was previously prompted to do by brew)

I also have an M1 chip and if it matters, I have other tools installed in my laptop like XCode, Anaconda, Java, etc.,

hnsvhns
  • 31
  • 5
  • 1
    Do you have OCaml installed via opam or via your package manager? If the latter, uninstall OCaml and install it through opam – Lhooq Sep 03 '22 at 21:20
  • @Lhooq so I have tried doing what you said but unfortunately it still doesn't work. Same error still happens when I run ```sudo opam install ocamlfind ounit utop dune qcheck``` – hnsvhns Sep 04 '22 at 00:25
  • 1
    You don't need to run `sudo` to install anything through opam. It will install the libraries in `~/.opam` or `~/path/to/dir/_opam` if you have a local switch. – Lhooq Sep 04 '22 at 08:06
  • You should not need to use `sudo` to install packages with `opam`. If `opam` complains when you install your packages because you did not use `sudo`, you may need to check where your switch is installed. – Stevendeo Sep 05 '22 at 15:20
  • The error message points to a problem with either your clang installation or an permission issue. Have you succeeded to compile any OCaml source file? – octachron Sep 05 '22 at 16:18

0 Answers0