Error when installing several opam packages

I am following a fairly straightforward tutorial for setting up an OCaml development environment for a university course which has me doing the following steps:

OCaml is well-supported in macOS, so the installation process is fairly straightforward.

  1. Install the Homebrew package manager for macOS.
  2. Install the following system packages using Homebrew:

brew install make m4 gcc pkg-config fswatch

  1. Next, install the opam package manager for installing and maintaining different OCaml libraries. Execute the following lines from the terminal:
brew install opam 
opam init -y --compiler=5.1.0 
eval $(opam env) 
opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server 
opam user-setup install
  1. Once done, add the following line to your ~/.bashrc, ~/.zshrc, and/or ~/.profile files (if they exist, otherwise create the file as appropriate for your shell, e.g., ~/.bashrc):

eval $(opam env)

  1. Close your terminal window and start a new one.To check that your OCaml is correctly installed, run ocamlc --version from the terminal. You should get the output 5.1.0, which is the version of the OCaml compiler we have just installed.

Except when I run the opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server command I am greeted with the following terminal output:

➜ opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server

[NOTE] Package ocamlformat-rpc is already installed (current version is removed).
[NOTE] Package dune is already installed (current version is 3.12.2).
Constructing initial basis...
Number of 0-1 knapsack inequalities = 6202
Constructing conflict graph...
Conflict graph has 1161 + 337 = 1498 vertices
The following actions will be performed:
  βˆ— install cppo                1.6.9    [required by utop]
  βˆ— install spawn               v0.15.1  [required by ocaml-lsp-server]
  βˆ— install xdg                 3.12.2   [required by ocaml-lsp-server, utop]
  βˆ— install num                 1.5
  βˆ— install menhirSdk           20231231 [required by menhir]
  βˆ— install ocamlfind           1.9.6    [required by user-setup, utop]
  βˆ— install menhirLib           20231231 [required by menhir]
  βˆ— install dune-build-info     3.12.2   [required by ocaml-lsp-server]
  βˆ— install re                  1.11.0   [required by ocamlformat, ocaml-lsp-server, user-setup]
  βˆ— install chrome-trace        3.12.2   [required by ocaml-lsp-server]
  βˆ— install menhirCST           20231231 [required by menhir]
  βˆ— install trie                1.0.0    [required by mew]
  βˆ— install either              1.0.0    [required by ocamlformat-lib]
  βˆ— install pp                  1.2.0    [required by ocaml-lsp-server]
  βˆ— install ocaml-version       3.6.3    [required by ocamlformat-lib]
  βˆ— install result              1.5      [required by ocamlformat-lib]
  βˆ— install csexp               1.5.2    [required by ocaml-lsp-server]
  βˆ— install ordering            3.12.2   [required by ocaml-lsp-server]
  βˆ— install camlp-streams       5.0.1    [required by ocaml-lsp-server]
  βˆ— install sexplib0            v0.16.0  [required by base]
  βˆ— install fix                 20230505 [required by ocamlformat-lib]
  βˆ— install yojson              2.1.2    [required by ocaml-lsp-server]
  βˆ— install topkg               1.0.7    [required by astring, uutf]
  βˆ— install base-bytes          base     [required by ocp-indent]
  βˆ— install menhir              20231231
  βˆ— install mew                 0.1.0    [required by mew_vi]
  βˆ— install ocamlformat-rpc-lib 0.26.1   [required by ocaml-lsp-server]
  βˆ— install merlin-lib          4.13-501 [required by ocaml-lsp-server]
  βˆ— install dune-configurator   3.12.2   [required by base]
  βˆ— install dyn                 3.12.2   [required by ocaml-lsp-server]
  βˆ— install ppx_yojson_conv_lib v0.16.0  [required by ocaml-lsp-server]
  βˆ— install uutf                1.0.3    [required by ocaml-lsp-server]
  βˆ— install uucp                15.1.0   [required by uuseg, zed]
  βˆ— install react               1.2.2    [required by utop]
  βˆ— install astring             0.8.5    [required by ocaml-lsp-server]
  βˆ— install ocplib-endian       1.2      [required by lwt]
  βˆ— install ocp-indent          1.8.1    [required by user-setup]
  βˆ— install base                v0.16.3  [required by ocamlformat-lib]
  βˆ— install stdune              3.12.2   [required by ocaml-lsp-server]
  βˆ— install ocamlc-loc          3.12.2   [required by ocaml-lsp-server]
  βˆ— install uuseg               15.1.0   [required by ocamlformat-lib]
  βˆ— install mew_vi              0.5.0    [required by lambda-term]
  βˆ— install fpath               0.7.3    [required by ocamlformat-lib]
  βˆ— install lwt                 5.7.0    [required by utop]
  βˆ— install user-setup          0.7
  βˆ— install stdio               v0.16.0  [required by ocamlformat-lib]
  βˆ— install fiber               3.7.0    [required by ocaml-lsp-server]
  βˆ— install dune-rpc            3.12.2   [required by ocaml-lsp-server]
  βˆ— install zed                 3.2.3    [required by utop]
  βˆ— install lwt_react           1.2.0    [required by utop]
  βˆ— install logs                0.7.0    [required by utop]
  βˆ— install ocamlformat-lib     0.26.1   [required by ocamlformat]
  βˆ— install ocaml-lsp-server    1.17.0
  βˆ— install lambda-term         3.3.2    [required by utop]
  βˆ— install ocamlformat         0.26.1
  βˆ— install utop                2.13.1
===== βˆ— 56 =====

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved astring.0.8.5  (cached)
⬇ retrieved camlp-streams.5.0.1  (cached)
⬇ retrieved cppo.1.6.9  (cached)
⬇ retrieved csexp.1.5.2  (cached)
⬇ retrieved chrome-trace.3.12.2  (cached)
⬇ retrieved dune-configurator.3.12.2  (cached)
[ERROR] The compilation of csexp.1.5.2 failed at "dune build -p csexp -j 11 @install".
⬇ retrieved dune-build-info.3.12.2  (cached)
⬇ retrieved dyn.3.12.2  (cached)
⬇ retrieved either.1.0.0  (cached)
⬇ retrieved fiber.3.7.0  (cached)
⬇ retrieved dune-rpc.3.12.2  (cached)
[ERROR] The compilation of dune-build-info.3.12.2 failed at "dune build -p dune-build-info -j 11 @install".
⬇ retrieved fix.20230505  (cached)
⬇ retrieved lambda-term.3.3.2  (cached)
⬇ retrieved fpath.0.7.3  (cached)
⬇ retrieved logs.0.7.0  (cached)
[ERROR] The compilation of either.1.0.0 failed at "dune build -p either -j 11 @install".
[ERROR] The compilation of chrome-trace.3.12.2 failed at "dune build -p chrome-trace -j 11 @install".
βˆ— installed cppo.1.6.9
⬇ retrieved lwt.5.7.0  (cached)
⬇ retrieved lwt_react.1.2.0  (cached)
⬇ retrieved menhir.20231231  (cached)
⬇ retrieved menhirCST.20231231  (cached)
⬇ retrieved menhirSdk.20231231  (cached)
[ERROR] The compilation of menhirCST.20231231 failed at "dune build -p menhirCST -j 11".
⬇ retrieved menhirLib.20231231  (cached)
⬇ retrieved mew.0.1.0  (cached)
⬇ retrieved merlin-lib.4.13-501  (cached)
⬇ retrieved mew_vi.0.5.0  (cached)
⬇ retrieved num.1.5  (cached)
⬇ retrieved ocaml-version.3.6.3  (cached)
⬇ retrieved ocaml-lsp-server.1.17.0  (cached)
[ERROR] The compilation of menhirLib.20231231 failed at "dune build -p menhirLib -j 11".
[ERROR] The compilation of menhirSdk.20231231 failed at "dune build -p menhirSdk -j 11".
[ERROR] The compilation of fix.20230505 failed at "dune build -p fix -j 11".
[ERROR] The compilation of camlp-streams.5.0.1 failed at "dune build -p camlp-streams -j 11 @install".
⬇ retrieved base.v0.16.3  (cached)
⬇ retrieved ocamlfind.1.9.6  (cached)
⬇ retrieved ocamlformat.0.26.1  (cached)
⬇ retrieved ocamlformat-lib.0.26.1  (cached)
⬇ retrieved ocamlformat-rpc-lib.0.26.1  (cached)
⬇ retrieved ocp-indent.1.8.1  (cached)
⬇ retrieved ocplib-endian.1.2  (cached)
⬇ retrieved pp.1.2.0  (cached)
⬇ retrieved ppx_yojson_conv_lib.v0.16.0  (cached)
[ERROR] The compilation of ocaml-version.3.6.3 failed at "dune build -p ocaml-version -j 11 @install".
⬇ retrieved ocamlc-loc.3.12.2  (cached)
⬇ retrieved re.1.11.0  (cached)
⬇ retrieved result.1.5  (cached)
⬇ retrieved sexplib0.v0.16.0  (cached)
⬇ retrieved spawn.v0.15.1  (cached)
⬇ retrieved stdio.v0.16.0  (cached)
[ERROR] The compilation of spawn.v0.15.1 failed at "dune build -p spawn -j 11 @install".
[ERROR] The compilation of result.1.5 failed at "dune build -p result -j 11".
⬇ retrieved react.1.2.2  (cached)
[ERROR] The compilation of pp.1.2.0 failed at "dune build -p pp -j 11 @install".
⬇ retrieved ordering.3.12.2  (cached)
⬇ retrieved trie.1.0.0  (cached)
⬇ retrieved user-setup.0.7  (cached)
[ERROR] The compilation of ocamlfind.1.9.6 failed at "make opt".
⬇ retrieved topkg.1.0.7  (cached)
⬇ retrieved utop.2.13.1  (cached)
⬇ retrieved stdune.3.12.2  (cached)
⬇ retrieved uuseg.15.1.0  (cached)
⬇ retrieved uutf.1.0.3  (cached)
[ERROR] The compilation of ordering.3.12.2 failed at "dune build -p ordering -j 11 @install".
⬇ retrieved uucp.15.1.0  (cached)
⬇ retrieved yojson.2.1.2  (cached)
⬇ retrieved zed.3.2.3  (cached)
[ERROR] The compilation of trie.1.0.0 failed at "dune build -p trie -j 11".
[ERROR] The compilation of sexplib0.v0.16.0 failed at "dune build -p sexplib0 -j 11".
[ERROR] The compilation of re.1.11.0 failed at "dune build -p re -j 11".
[ERROR] The compilation of num.1.5 failed at "make PROFILE=release opam-modern".
⬇ retrieved xdg.3.12.2  (cached)
[ERROR] The compilation of yojson.2.1.2 failed at "dune build -p yojson -j 11 @install".
[ERROR] The compilation of xdg.3.12.2 failed at "dune build -p xdg -j 11 @install".

#=== ERROR while compiling yojson.2.1.2 =======================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/yojson.2.1.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p yojson -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/yojson-34019-9dbc97.env
# output-file ~/.opam/log/yojson-34019-9dbc97.out
### output ###
# [...]
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/yojson.2.1.2/_build/default/lib/yojson.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# File "bin/dune", line 2, characters 7-12:
# 2 |  (name ydump)
#            ^^^^^
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -o bin/ydump.exe lib/yojson.cmxa bin/.ydump.eobjs/native/dune__exe__Ydump.cmx)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/yojson.2.1.2/_build/default/lib/yojson.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling xdg.3.12.2 =========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/xdg.3.12.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p xdg -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/xdg-34019-889695.env
# output-file ~/.opam/log/xdg-34019-889695.out
### output ###
# [...]
# 10 |   (:include c_library_flags.sexp))
# 11 |  (foreign_stubs
# 12 |   (language c)
# 13 |   (names xdg_stubs))
# 14 |  (synopsis "[Internal] XDG base directories specification implementation")
# 15 |  (instrumentation
# 16 |   (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/xdg -o otherlibs/xdg/xdg.cmxs otherlibs/xdg/xdg.cmxa)
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/xdg.3.12.2/_build/default/otherlibs/xdg/xdg.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/xdg.3.12.2/_build/default/otherlibs/xdg/libxdg_stubs.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling trie.1.0.0 =========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/trie.1.0.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p trie -j 11
# exit-code   1
# env-file    ~/.opam/log/trie-34019-329e13.env
# output-file ~/.opam/log/trie-34019-329e13.out
### output ###
# File "src/dune", line 1, characters 0-79:
# 1 | (library
# 2 |   (name trie)
# 3 |   (public_name trie)
# 4 |   (flags (:standard -safe-string)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -safe-string -g -shared -linkall -I src -o src/trie.cmxs src/trie.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/trie.1.0.0/_build/default/src/trie.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling spawn.v0.15.1 ======================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p spawn -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/spawn-34019-34bfaa.env
# output-file ~/.opam/log/spawn-34019-34bfaa.out
### output ###
# File "src/dune", line 1, characters 0-396:
# [...]
#  2 |  (name spawn)
#  3 |  (public_name spawn)
# ....
# 11 |  ;; c_library_flags. However, this would require testing that it is
# 12 |  ;; supported.
# 13 |  (libraries unix threads))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/spawn.cmxs src/spawn.cmxa)
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1/_build/default/src/libspawn_stubs.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1/_build/default/src/spawn.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling sexplib0.v0.16.0 ===================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/sexplib0.v0.16.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p sexplib0 -j 11
# exit-code   1
# env-file    ~/.opam/log/sexplib0-34019-00087f.env
# output-file ~/.opam/log/sexplib0-34019-00087f.out
### output ###
# File "src/dune", line 1, characters 0-79:
# 1 | (library (name sexplib0) (public_name sexplib0)
# 2 |  (preprocess no_preprocessing))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/sexplib0.cmxs src/sexplib0.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/sexplib0.v0.16.0/_build/default/src/sexplib0.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling result.1.5 =========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/result.1.5
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p result -j 11
# exit-code   1
# env-file    ~/.opam/log/result-34019-faa45e.env
# output-file ~/.opam/log/result-34019-faa45e.out
### output ###
# File "dune", line 1, characters 0-64:
# 1 | (library
# 2 |  (name result)
# 3 |  (public_name result)
# 4 |  (modules result))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I . -o result.cmxs result.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/result.1.5/_build/default/result.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling re.1.11.0 ==========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/re.1.11.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p re -j 11
# exit-code   1
# env-file    ~/.opam/log/re-34019-ce7d01.env
# output-file ~/.opam/log/re-34019-ce7d01.out
### output ###
# [...]
# 25 | (library
# 26 |  (name re_posix)
# 27 |  (public_name re.posix)
# 28 |  (wrapped false)
# 29 |  (modules re_posix)
# 30 |  (synopsis "Deprecated. Use Re.Posix")
# 31 |  (libraries re))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -w -50 -g -shared -linkall -I deprecated -o deprecated/re_posix.cmxs deprecated/re_posix.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/re.1.11.0/_build/default/deprecated/re_posix.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling pp.1.2.0 ===========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/pp.1.2.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p pp -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/pp-34019-3b7bbd.env
# output-file ~/.opam/log/pp-34019-3b7bbd.out
### output ###
# File "src/dune", line 1, characters 0-27:
# 1 | (library
# 2 |  (public_name pp))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/pp.cmxs src/pp.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/pp.1.2.0/_build/default/src/pp.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling ordering.3.12.2 ====================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/ordering.3.12.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ordering -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/ordering-34019-d10882.env
# output-file ~/.opam/log/ordering-34019-d10882.out
### output ###
# [...]
# File "otherlibs/ordering/dune", line 1, characters 0-124:
# 1 | (library
# 2 |  (name ordering)
# 3 |  (public_name ordering)
# 4 |  (synopsis "Element ordering.")
# 5 |  (instrumentation
# 6 |   (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/ordering -o otherlibs/ordering/ordering.cmxs otherlibs/ordering/ordering.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ordering.3.12.2/_build/default/otherlibs/ordering/ordering.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling ocamlfind.1.9.6 ====================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/ocamlfind.1.9.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build make opt
# exit-code   2
# env-file    ~/.opam/log/ocamlfind-34019-0c01e7.env
# output-file ~/.opam/log/ocamlfind-34019-0c01e7.out
### output ###
# [...]
# File "frontend.ml", line 859, characters 10-39:
# 859 |           Fl_package_base.package_users predicates1 packages1
#                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Warning 6 [labels-omitted]: label preds was omitted in the application of this function.
# ocamlopt -I +compiler-libs -g -o ocamlfind_opt findlib.cmxa unix.cmxa \
# 		   -I +unix -I +dynlink ocaml_args.cmx frontend.cmx
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ocamlfind.1.9.6/src/findlib/findlib.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# make[1]: *** [ocamlfind_opt] Error 2
# make: *** [opt] Error 2


#=== ERROR while compiling ocaml-version.3.6.3 ================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/ocaml-version.3.6.3
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ocaml-version -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/ocaml-version-34019-a302cf.env
# output-file ~/.opam/log/ocaml-version-34019-a302cf.out
### output ###
# File "dune", line 1, characters 0-60:
# 1 | (library
# 2 |  (name ocaml_version)
# 3 |  (public_name ocaml-version))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I . -o ocaml_version.cmxs ocaml_version.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ocaml-version.3.6.3/_build/default/ocaml_version.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling num.1.5 ============================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/num.1.5
# command     ~/.opam/opam-init/hooks/sandbox.sh build make PROFILE=release opam-modern
# exit-code   2
# env-file    ~/.opam/log/num-34019-0e4664.env
# output-file ~/.opam/log/num-34019-0e4664.out
### output ###
# [...]
# ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_flags.ml
# ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c ratio.ml
# ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num.ml
# ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_status.ml
# ocamlmklib -o nums -oc nums -linkall int_misc.cmx nat.cmx big_int.cmx arith_flags.cmx ratio.cmx num.cmx arith_status.cmx
# ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -I . -shared -o nums.cmxs nums.cmxa
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/num.1.5/src/libnums.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/num.1.5/src/nums.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# make[1]: *** [nums.cmxs] Error 2
# make: *** [all] Error 2


#=== ERROR while compiling menhirSdk.20231231 =================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/menhirSdk.20231231
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirSdk -j 11
# exit-code   1
# env-file    ~/.opam/log/menhirSdk-34019-4ede18.env
# output-file ~/.opam/log/menhirSdk-34019-4ede18.out
### output ###
# File "sdk/dune", line 16, characters 0-127:
# 16 | (library
# 17 |   (name menhirSdk)
# 18 |   (public_name menhirSdk)
# 19 |   (synopsis "Toolkit for postprocessing Menhir automata (.cmly files)")
# 20 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I sdk -o sdk/menhirSdk.cmxs sdk/menhirSdk.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirSdk.20231231/_build/default/sdk/menhirSdk.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling menhirLib.20231231 =================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/menhirLib.20231231
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirLib -j 11
# exit-code   1
# env-file    ~/.opam/log/menhirLib-34019-d70bba.env
# output-file ~/.opam/log/menhirLib-34019-d70bba.out
### output ###
# [...]
# File "lib/pack/dune", line 18, characters 0-137:
# 18 | (library
# 19 |   (name menhirLib)
# 20 |   (public_name menhirLib)
# 21 |   (synopsis "Runtime support for code generated by Menhir")
# 22 |   (modules menhirLib)
# 23 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I lib/pack -o lib/pack/menhirLib.cmxs lib/pack/menhirLib.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirLib.20231231/_build/default/lib/pack/menhirLib.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling menhirCST.20231231 =================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/menhirCST.20231231
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirCST -j 11
# exit-code   1
# env-file    ~/.opam/log/menhirCST-34019-48a0ff.env
# output-file ~/.opam/log/menhirCST-34019-48a0ff.out
### output ###
# [...]
# File "cst/dune", line 6, characters 0-134:
#  6 | (library
#  7 |   (name menhirCST)
#  8 |   (public_name menhirCST)
#  9 |   (synopsis "Runtime support for code generated by Menhir")
# 10 |   (modules Settle)
# 11 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I cst -o cst/menhirCST.cmxs cst/menhirCST.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirCST.20231231/_build/default/cst/menhirCST.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling fix.20230505 =======================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/fix.20230505
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p fix -j 11
# exit-code   1
# env-file    ~/.opam/log/fix-34019-370b6c.env
# output-file ~/.opam/log/fix-34019-370b6c.out
### output ###
# File "src/dune", line 1, characters 0-118:
# 1 | (library
# 2 |   (name fix)
# 3 |   (public_name fix)
# 4 |   (synopsis "An on-demand, incremental fixed point computation algorithm")
# 5 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/fix.cmxs src/fix.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/fix.20230505/_build/default/src/fix.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling either.1.0.0 =======================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/either.1.0.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p either -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/either-34019-f0121f.env
# output-file ~/.opam/log/either-34019-f0121f.out
### output ###
# File "src/dune", line 1, characters 0-76:
# 1 | (library
# 2 |  (name either)
# 3 |  (public_name either)
# 4 |  (modules either either_intf))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/either.cmxs src/either.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/either.1.0.0/_build/default/src/either.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling dune-build-info.3.12.2 =============================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/dune-build-info.3.12.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p dune-build-info -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/dune-build-info-34019-cd4700.env
# output-file ~/.opam/log/dune-build-info-34019-cd4700.out
### output ###
# File "otherlibs/dune-build-info/src/dune", line 1, characters 0-245:
# [...]
#  5 |  (special_builtin_support
#  6 |   (build_info
#  7 |    (data_module build_info_data)
#  8 |    (api_version 1)))
#  9 |  (instrumentation
# 10 |   (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/dune-build-info/src -o otherlibs/dune-build-info/src/build_info.cmxs otherlibs/dune-build-info/src/build_info.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/dune-build-info.3.12.2/_build/default/otherlibs/dune-build-info/src/build_info.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling csexp.1.5.2 ========================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/csexp.1.5.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p csexp -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/csexp-34019-2f1355.env
# output-file ~/.opam/log/csexp-34019-2f1355.out
### output ###
# File "src/dune", line 1, characters 0-30:
# 1 | (library
# 2 |  (public_name csexp))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/csexp.cmxs src/csexp.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/csexp.1.5.2/_build/default/src/csexp.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling chrome-trace.3.12.2 ================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/chrome-trace.3.12.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p chrome-trace -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/chrome-trace-34019-27b6d4.env
# output-file ~/.opam/log/chrome-trace-34019-27b6d4.out
### output ###
# [...]
# File "otherlibs/chrome-trace/src/dune", line 1, characters 0-174:
# 1 | (library
# 2 |  (name chrome_trace)
# 3 |  (public_name chrome-trace)
# 4 |  (synopsis "Emit catapult trace files, compatible with chrome://tracing")
# 5 |  (instrumentation
# 6 |   (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/chrome-trace/src -o otherlibs/chrome-trace/src/chrome_trace.cmxs otherlibs/chrome-trace/src/chrome_trace.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/chrome-trace.3.12.2/_build/default/otherlibs/chrome-trace/src/chrome_trace.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)


#=== ERROR while compiling camlp-streams.5.0.1 ================================#
# context     2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path        ~/.opam/5.1.0/.opam-switch/build/camlp-streams.5.0.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p camlp-streams -j 11 @install
# exit-code   1
# env-file    ~/.opam/log/camlp-streams-34019-c5de61.env
# output-file ~/.opam/log/camlp-streams-34019-c5de61.out
### output ###
# [...]
# File "_build/.dune/default/dune", line 55, characters 0-144:
# 55 | (library
# 56 |   (name camlp_streams)
# 57 |   (public_name camlp-streams)
# 58 |   (modules :standard)
# 59 |   (wrapped false)
# 60 |   (flags :standard (:include flags.sexp)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -w -9 -g -shared -linkall -I . -o camlp_streams.cmxs camlp_streams.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/camlp-streams.5.0.1/_build/default/camlp_streams.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build camlp-streams   5.0.1
β”‚ Ξ» build chrome-trace    3.12.2
β”‚ Ξ» build csexp           1.5.2
β”‚ Ξ» build dune-build-info 3.12.2
β”‚ Ξ» build either          1.0.0
β”‚ Ξ» build fix             20230505
β”‚ Ξ» build menhirCST       20231231
β”‚ Ξ» build menhirLib       20231231
β”‚ Ξ» build menhirSdk       20231231
β”‚ Ξ» build num             1.5
β”‚ Ξ» build ocaml-version   3.6.3
β”‚ Ξ» build ocamlfind       1.9.6
β”‚ Ξ» build ordering        3.12.2
β”‚ Ξ» build pp              1.2.0
β”‚ Ξ» build re              1.11.0
β”‚ Ξ» build result          1.5
β”‚ Ξ» build sexplib0        v0.16.0
β”‚ Ξ» build spawn           v0.15.1
β”‚ Ξ» build trie            1.0.0
β”‚ Ξ» build xdg             3.12.2
β”‚ Ξ» build yojson          2.1.2
└─
β”Œβ”€ The following changes have been performed (the rest was aborted)
β”‚ βˆ— install cppo 1.6.9
└─

The former state can be restored with:
    /opt/homebrew/bin/opam switch import "/Users/davidmek/.opam/5.1.0/.opam-switch/backup/state-20240112210157.export"

No one, including the course staff, can provide any meaningful suggestions about these linker errors during the build process. For reference, I am on an M2 Pro MacBook Pro on macOS 14.2.1. GCC stats below:

Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I have tried uninstalling and reinstalling Xcode command line tools, and redoing each one of the steps in the instructor tutorial but to no avail. I have OCaml version 5.1.0 installed. Any suggestion on the matter would be greatly appreciated.

Please do not cross post.

1 Like

Sorry. Do you want me to remove the post here?

There’s no need to remove the post, but you can mark it as solved (Daniel’s reply) in case anyone mistakenly tries to answer.

1 Like