Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opam package installation issue on an Apple silicon MacBook Pro #5783

Closed
david-mek opened this issue Jan 12, 2024 · 11 comments
Closed

Opam package installation issue on an Apple silicon MacBook Pro #5783

david-mek opened this issue Jan 12, 2024 · 11 comments

Comments

@david-mek
Copy link

david-mek commented Jan 12, 2024

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.

@kit-ty-kate
Copy link
Member

Could you try again after a brew remove gcc ?

@david-mek
Copy link
Author

No change in output when running opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server after brew remove gcc.

@yawaramin
Copy link
Contributor

I think the instructions are outdated. The ocamlformat-rpc and user-setup packages are redundant for you, so you shouldn't install those. Also, num is long since deprecated in favour of zarith.

Also, before you install anything, make sure your copy of opam-repository is fresh:

opam update

That said, the install worked for me in a new 5.1.0 switch with this command:

opam install dune utop num menhir ocamlformat ocaml-lsp-server

Ignore the warning about needing package user-setup, you don't need that since you're going to use ocamlformat, not ocp-indent.

@yawaramin
Copy link
Contributor

yawaramin commented Jan 12, 2024

One piece of advice: for long extracts, use the <details> tag to let readers expand/collapse it as they prefer. GitHub makes it really easy to use with a slash command. Just press / on an empty line and the menu will pop up.

@david-mek
Copy link
Author

david-mek commented Jan 12, 2024

Unfortunately, running opam update and opam install dune utop num menhir ocamlformat ocaml-lsp-server still causes the same linker errors during compilation. Thanks for the tip on long extracts.

Error report <><> 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 └─ ╶─ No changes have been performed

@kit-ty-kate
Copy link
Member

What does which gcc cc ar ld tell you? My gut feeling from a quick duckduckgoing is that ar is the faulty tool somehow installed through some previously installed homebrew package and it’s not mixing well with the rest of the usual Apple tools (i’ve seen that happened plenty of time in the past, though the error message is different this time around)

@david-mek
Copy link
Author

david-mek commented Jan 13, 2024

It says:

➜ which gcc cc ar ld
/usr/bin/gcc
/usr/bin/cc
/opt/homebrew/opt/binutils/bin/ar
/usr/bin/ld

I think you may be right. ar is a part of the binutils homebrew package. What's the best way to proceed?

Edit: I did brew uninstall binutils and now a significantly higher number of packages are installing and building.

New which:

➜ which gcc cc ar ld
/usr/bin/gcc
/usr/bin/cc
/usr/bin/ar
/usr/bin/ld

New opam install dune utop num menhir ocamlformat ocaml-lsp-server output:

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ λ build ocp-indent 1.8.1
│ λ build uutf       1.0.3
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install astring             0.8.5
│ ∗ install base                v0.16.3
│ ∗ install base-bytes          base
│ ∗ install camlp-streams       5.0.1
│ ∗ install chrome-trace        3.12.2
│ ∗ install csexp               1.5.2
│ ∗ install dune-build-info     3.12.2
│ ∗ install dune-configurator   3.12.2
│ ∗ install dune-rpc            3.12.2
│ ∗ install dyn                 3.12.2
│ ∗ install either              1.0.0
│ ∗ install fiber               3.7.0
│ ∗ install fix                 20230505
│ ∗ install fpath               0.7.3
│ ∗ install logs                0.7.0
│ ∗ install lwt                 5.7.0
│ ∗ install lwt_react           1.2.0
│ ∗ install menhir              20231231
│ ∗ install menhirCST           20231231
│ ∗ install menhirLib           20231231
│ ∗ install menhirSdk           20231231
│ ∗ install merlin-lib          4.13-501
│ ∗ install mew                 0.1.0
│ ∗ install mew_vi              0.5.0
│ ∗ install num                 1.5
│ ∗ install ocaml-version       3.6.3
│ ∗ install ocamlc-loc          3.12.2
│ ∗ install ocamlfind           1.9.6
│ ∗ install ocamlformat-rpc-lib 0.26.1
│ ∗ install ocplib-endian       1.2
│ ∗ install ordering            3.12.2
│ ∗ install pp                  1.2.0
│ ∗ install ppx_yojson_conv_lib v0.16.0
│ ∗ install re                  1.11.0
│ ∗ install react               1.2.2
│ ∗ install result              1.5
│ ∗ install sexplib0            v0.16.0
│ ∗ install spawn               v0.15.1
│ ∗ install stdio               v0.16.0
│ ∗ install stdune              3.12.2
│ ∗ install topkg               1.0.7
│ ∗ install trie                1.0.0
│ ∗ install uucp                15.1.0
│ ∗ install xdg                 3.12.2
│ ∗ install yojson              2.1.2
└─

@kit-ty-kate
Copy link
Member

I’m guessing cmdliner previously built in a faulty state so opam reinstall cmdliner should fix that. Or if not, try reinstalling the whole switch using opam switch reinstall

@david-mek
Copy link
Author

Everything appears to be working now. Thank you so much for your help! I would have never thought of a random homebrew package being the issue xD.

@dbuenzli
Copy link
Contributor

This happens so often, I still think we should have this

@kit-ty-kate
Copy link
Member

This happens so often, I still think we should have this

that’s fair. I’ve opened #5784 to have it documented somewhere at the very least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants