Closed david-mek closed 10 months ago
Could you try again after a brew remove gcc
?
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
.
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.
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.
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.
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)
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
└─
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
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.
This happens so often, I still think we should have this
that’s fair. I’ve opened https://github.com/ocaml/opam/issues/5784 to have it documented somewhere at the very least
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.
brew install make m4 gcc pkg-config fswatch
opam
package manager for installing and maintaining different OCaml libraries. Execute the following lines from the terminal:~/.bashrc
,~/.zshrc
, and/or~/.profile
files (if they exist, otherwise create the file as appropriate for your shell, e.g.,~/.bashrc
):eval $(opam env)
ocamlc --version
from the terminal. You should get the output5.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: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:
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.