I ran into some issues here recently trying to get opam to install some packages. I was getting the following message:
10:49 $ opam install dune
The following actions will be performed:
β install dune 2.7.1
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
[dune.2.7.1] downloaded from cache at https://opam.ocaml.org/cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> π«
[ERROR] The compilation of dune failed at "/Users/jdonaldson/.opam/opam-init/hooks/sandbox.sh build ocaml bootstrap.ml -j 7".
#=== ERROR while compiling dune.2.7.1 =========================================#
# context 2.0.7 | macos/x86_64 | ocaml-base-compiler.4.11.1 | https://opam.ocaml.org#b9edad04
# path ~/.opam/default/.opam-switch/build/dune.2.7.1
# command ~/.opam/opam-init/hooks/sandbox.sh build ocaml bootstrap.ml -j 7
# exit-code 2
# env-file ~/.opam/log/dune-39298-6cc03f.env
# output-file ~/.opam/log/dune-39298-6cc03f.out
### output ###
# ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot unix.cma boot/libs.ml boot/duneboot.ml
# File "boot/duneboot.ml", line 1:
# Error: Invalid import of Libs, compiled with -unsafe-string.
# This compiler has been configured in strict safe-string mode (-force-safe-string)
Thereβs several other packages Iβm interested in installing that are failing with the same errors:
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
ββ The following actions failed
β Ξ» build camlp5 8.00~alpha04
β Ξ» build dune 2.7.1
β Ξ» build ocamlbuild 0.14.0
β Ξ» build ocamlfind 1.8.1
I also cannot switch to an older version that does not enforce safe strings. I tried 4.06:
10:57 $ opam switch create 4.06.0
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
[ocaml-base-compiler.4.06.0] downloaded from cache at https://opam.ocaml.org/cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> π«
β installed base-bigarray.base
β installed base-threads.base
β installed base-unix.base
[ERROR] The compilation of ocaml-base-compiler failed at "/Users/jdonaldson/.opam/opam-init/hooks/sandbox.sh build make world".
#=== ERROR while compiling ocaml-base-compiler.4.06.0 =========================#
# context 2.0.7 | macos/x86_64 | | https://opam.ocaml.org#b9edad04
# path ~/.opam/4.06.0/.opam-switch/build/ocaml-base-compiler.4.06.0
# command ~/.opam/opam-init/hooks/sandbox.sh build make world
# exit-code 2
# env-file ~/.opam/log/ocaml-base-compiler-42289-c743ac.env
# output-file ~/.opam/log/ocaml-base-compiler-42289-c743ac.out
### output ###
# [...]
# cc -O2 -pipe -c -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -I../byterun -o skeleton.o skeleton.c
# cc -O2 -pipe -c -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -I../byterun -o symtab.o symtab.c
# cc -O2 -pipe -c -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -I../byterun -o verbose.o verbose.c
# cc -O2 -pipe -c -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -I../byterun -o warshall.o warshall.c
# cc -O2 -pipe -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -Wl,-no_compact_unwind -o ocamlyacc closure.o error.o lalr.o lr0.o main.o mkpar.o output.o reader.o skeleton.o symtab.o verbose.o warshall.o
# cp yacc/ocamlyacc boot/ocamlyacc
# /Applications/Xcode.app/Contents/Developer/usr/bin/make -C stdlib \
# COMPILER="../boot/ocamlc -use-prims ../byterun/primitives" all
# ../boot/ocamlrun ../boot/ocamlc -use-prims ../byterun/primitives -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bin-annot -nostdlib -safe-string -strict-formats `sh ./Compflags camlinternalFormatBasics.cmi` -c camlinternalFormatBasics.mli
# Fatal error: exception Invalid_argument("Sys.getcwd not implemented")
# make[1]: *** [camlinternalFormatBasics.cmi] Error 2
# make: *** [coldstart] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
ββ The following actions failed
β Ξ» build ocaml-base-compiler 4.06.0
ββ
Iβve been using opam/ocaml for a few years now, and had problems with safe strings before, but the issue was always with packages. This seems to be a low level configuration option that Iβm missing.