ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 357 forks source link

Can't install packages - "Undefined symbols for architecture x86_64" on macOS #4837

Closed raphaelrk closed 2 years ago

raphaelrk commented 3 years ago

Having issues with the installation of many opam packages, all stating "Undefined symbols for architecture x86_64".

Examples

Trying to install merlin:

~> opam install merlin
[WARNING] Opam package conf-libX11.1 depends on the following system package that can no longer be found: xquartz
yThe following actions will be performed:
  ↻ recompile conf-libX11       1         [upstream or system changes]
  ∗ install   biniou            1.2.1     [required by yojson]
  ∗ install   yojson            1.7.0     [required by merlin]
  ∗ install   dot-merlin-reader 4.1       [required by merlin]
  ∗ install   merlin            4.3.1-412
===== ∗ 4   ↻ 1 =====
Do you want to continue? [Y/n] y

The following system packages will first need to be installed:
    xquartz

<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><>  🐫 
Let opam run your package manager to install the required system packages?
(answer 'n' for other options) [Y/n] y
+ /usr/local/bin/brew "install" "xquartz"
- Warning: Cask 'xquartz' is already installed.
- 
- To re-install xquartz, run:
-   brew reinstall xquartz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⬇ retrieved merlin.4.3.1-412  (cached)
⊘ removed   conf-libX11.1
∗ installed conf-libX11.1
⬇ retrieved dot-merlin-reader.4.1  (cached)
⬇ retrieved yojson.1.7.0  (cached)
⬇ retrieved biniou.1.2.1  (cached)
[ERROR] The compilation of biniou.1.2.1 failed at "dune build -p biniou -j 7".

#=== ERROR while compiling biniou.1.2.1 =======================================#
# context     2.1.0 | macos/x86_64 |  | https://opam.ocaml.org#81d2d054
# path        ~/.opam/4.12.0/.opam-switch/build/biniou.1.2.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p biniou -j 7
# exit-code   1
# env-file    ~/.opam/log/biniou-51247-404a21.env
# output-file ~/.opam/log/biniou-51247-404a21.out
### output ###
# Undefined symbols for architecture x86_64:
# [...]
#       _caml_globals in camlstartup7c73de.o
#   "_camlEasy_format__to_channel_inner_1534", referenced from:
#       _camlBi_io__output_view_of_tree_1526 in biniou.a(bi_io.o)
#   "_camlEasy_format__to_stdout_1103", referenced from:
#       _camlBi_io__print_view_of_tree_1523 in biniou.a(bi_io.o)
#   "_camlEasy_format__to_string_1086", referenced from:
#       _camlBi_io__view_of_tree_1520 in biniou.a(bi_io.o)
# ld: symbol(s) not found for architecture x86_64
# 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 biniou 1.2.1
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ↻ recompile conf-libX11 1
└─ 

Trying to install graphics:

~> opam install graphics
[WARNING] Opam package conf-libX11.1 depends on the following system package that can no longer be found: xquartz
The following actions will be performed:
  ↻ recompile conf-libX11   1     [upstream or system changes]
  ∗ install   graphics      5.1.2
  ↻ recompile ocamlfind     1.9.1 [uses graphics]
  ↻ recompile base-bytes    base  [uses ocamlfind]
  ↻ recompile zed           3.1.0 [uses base-bytes]
  ↻ recompile ocplib-endian 1.1   [uses base-bytes]
===== ∗ 1   ↻ 5 =====
Do you want to continue? [Y/n] y

The following system packages will first need to be installed:
    xquartz

<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><>  🐫 
Let opam run your package manager to install the required system packages?
(answer 'n' for other options) [Y/n] y
+ /usr/local/bin/brew "install" "xquartz"
- Warning: Cask 'xquartz' is already installed.
- 
- To re-install xquartz, run:
-   brew reinstall xquartz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⬇ retrieved ocplib-endian.1.1  (cached)
⬇ retrieved ocamlfind.1.9.1  (cached)
⬇ retrieved zed.3.1.0  (cached)
⊘ removed   conf-libX11.1
⊘ removed   ocplib-endian.1.1
⊘ removed   zed.3.1.0
⊘ removed   base-bytes.base
⊘ removed   ocamlfind.1.9.1
∗ installed conf-libX11.1
⬇ retrieved graphics.5.1.2  (cached)
[ERROR] The compilation of graphics.5.1.2 failed at "dune build -p graphics -j 7 @install".

#=== ERROR while compiling graphics.5.1.2 =====================================#
# context     2.1.0 | macos/x86_64 |  | https://opam.ocaml.org#81d2d054
# path        ~/.opam/4.12.0/.opam-switch/build/graphics.5.1.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p graphics -j 7 @install
# exit-code   1
# env-file    ~/.opam/log/graphics-52070-0f421a.env
# output-file ~/.opam/log/graphics-52070-0f421a.out
### output ###
# Undefined symbols for architecture x86_64:
# [...]
#       _caml_data_segments in camlstartup85a6d7.o
#   "_camlCsexp__entry", referenced from:
#       _caml_program in camlstartup85a6d7.o
#   "_camlCsexp__frametable", referenced from:
#       _caml_frametable in camlstartup85a6d7.o
#   "_camlCsexp__gc_roots", referenced from:
#       _caml_globals in camlstartup85a6d7.o
# ld: symbol(s) not found for architecture x86_64
# 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 graphics 5.1.2
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ⊘ remove    base-bytes    base
│ ⊘ remove    ocamlfind     1.9.1
│ ⊘ remove    ocplib-endian 1.1
│ ⊘ remove    zed           3.1.0
│ ↻ recompile conf-libX11   1
└─ 

The former state can be restored with:
    /usr/local/bin/opam switch import "/Users/raphaelrk/.opam/4.12.0/.opam-switch/backup/state-20210914025751.export"
Or you can retry to install your package selection with:
    /usr/local/bin/opam install --restore

Trying to install utop:

~> opam install utop
[WARNING] Opam package conf-libX11.1 depends on the following system package that can no longer be found: xquartz
The following actions will be performed:
  ↻ recompile conf-libX11   1     [upstream or system changes]
  ∗ install   ocamlfind     1.9.1 [required by utop]
  ∗ install   base-bytes    base  [required by zed]
  ∗ install   zed           3.1.0 [required by lambda-term]
  ∗ install   ocplib-endian 1.1   [required by lwt]
  ∗ install   lwt           5.4.2 [required by utop]
  ∗ install   lwt_react     1.1.4 [required by utop]
  ∗ install   lwt_log       1.1.1 [required by lambda-term]
  ∗ install   lambda-term   3.1.0 [required by utop]
  ∗ install   utop          2.8.0
===== ∗ 9   ↻ 1 =====
Do you want to continue? [Y/n] y

The following system packages will first need to be installed:
    xquartz

<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><>  🐫 
Let opam run your package manager to install the required system packages?
(answer 'n' for other options) [Y/n] y
+ /usr/local/bin/brew "install" "xquartz"
- Warning: Cask 'xquartz' is already installed.
- 
- To re-install xquartz, run:
-   brew reinstall xquartz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⬇ retrieved lwt_log.1.1.1  (cached)
⊘ removed   conf-libX11.1
∗ installed conf-libX11.1
⬇ retrieved lwt.5.4.2  (cached)
⬇ retrieved lwt_react.1.1.4  (cached)
⬇ retrieved ocamlfind.1.9.1  (cached)
⬇ retrieved utop.2.8.0  (cached)
⬇ retrieved ocplib-endian.1.1  (cached)
⬇ retrieved zed.3.1.0  (cached)
⬇ retrieved lambda-term.3.1.0  (cached)
∗ installed ocamlfind.1.9.1
∗ installed base-bytes.base
∗ installed ocplib-endian.1.1
[ERROR] The compilation of lwt.5.4.2 failed at "dune exec -p lwt src/unix/config/discover.exe -- --save --use-libev false".
∗ installed zed.3.1.0

#=== ERROR while compiling lwt.5.4.2 ==========================================#
# context     2.1.0 | macos/x86_64 |  | https://opam.ocaml.org#81d2d054
# path        ~/.opam/4.12.0/.opam-switch/build/lwt.5.4.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune exec -p lwt src/unix/config/discover.exe -- --save --use-libev false
# exit-code   1
# env-file    ~/.opam/log/lwt-52470-788a76.env
# output-file ~/.opam/log/lwt-52470-788a76.out
### output ###
# Undefined symbols for architecture x86_64:
# [...]
#       _caml_data_segments in camlstartup893245.o
#   "_camlCsexp__entry", referenced from:
#       _caml_program in camlstartup893245.o
#   "_camlCsexp__frametable", referenced from:
#       _caml_frametable in camlstartup893245.o
#   "_camlCsexp__gc_roots", referenced from:
#       _caml_globals in camlstartup893245.o
# ld: symbol(s) not found for architecture x86_64
# 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 lwt 5.4.2
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ↻ recompile conf-libX11   1
│ ∗ install   base-bytes    base
│ ∗ install   ocamlfind     1.9.1
│ ∗ install   ocplib-endian 1.1
│ ∗ install   zed           3.1.0
└─ 

The former state can be restored with:
    /usr/local/bin/opam switch import "/Users/raphaelrk/.opam/4.12.0/.opam-switch/backup/state-20210914025913.export"
Or you can retry to install your package selection with:
    /usr/local/bin/opam install --restore

opam config report

~> opam config report
# opam config report
# opam-version         2.1.0 
# self-upgrade         no
# system               arch=x86_64 os=macos os-distribution=homebrew os-version=11.5.2
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 7
# repositories         1 (http) (default repo at 81d2d054)
# pinned               0
# current-switch       4.12.0
[WARNING] Opam package conf-libX11.1 depends on the following system package that can no longer be found: xquartz
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /usr/local/lib/ocaml/stublibs:/usr/local/lib/ocaml
# ocaml:preinstalled   true
# ocaml:compiler       system
# ocaml-system:path    /usr/local/bin

More information

I'm on macOS Big Sur 11.5.2, have plenty of storage, and have gotten some packages to install:

~> opam list
# Packages matching: installed
# Name                # Installed # Synopsis
base-bigarray         base
base-bytes            base        Bytes library distributed with the OCaml compiler
base-threads          base
base-unix             base
camomile              1.0.2       A Unicode library
charInfo_width        1.1.0       Determine column width for a character
conf-libX11           1           Virtual package relying on an Xlib system installation
conf-pkg-config       2           Check if pkg-config is installed and create an opam switch local pkgconfig folder
cppo                  1.6.7       Code preprocessor like cpp for OCaml
csexp                 1.5.1       Parsing and printing of S-expressions in Canonical form
dune                  2.9.1       Fast, portable, and opinionated build system
dune-configurator     2.9.1       Helper library for gathering system configuration
easy-format           1.3.2       High-level and functional interface to the Format module of the OCaml standard library
menhirLib             20210419    Runtime support library for parsers generated by Menhir
menhirSdk             20210419    Compile-time library for auxiliary tools related to Menhir
mew                   0.1.0       Modal editing witch
mew_vi                0.5.0       Modal editing witch, VI interpreter
mmap                  1.1.0       File mapping functionality
ocaml                 4.12.0      The OCaml compiler (virtual package)
ocaml-config          2           OCaml Switch Configuration
ocaml-options-vanilla 1           Ensure that OCaml is compiled with no special options enabled
ocaml-system          4.12.0      The OCaml compiler (system version, from outside of opam)
ocamlbuild            0.14.0      OCamlbuild is a build system with builtin rules to easily build most OCaml projects.
ocamlfind             1.9.1       A library manager for OCaml
ocplib-endian         1.1         Optimised functions to read and write int16/32/64 from strings and bigarrays
react                 1.2.1       Declarative events and signals for OCaml
result                1.5         Compatibility Result module
seq                   base        Compatibility package for OCaml's standard iterator type starting from 4.07.
topkg                 1.0.3       The transitory OCaml software packager
trie                  1.0.0       Strict impure trie tree
zed                   3.1.0       Abstract engine for text edition in OCaml
kit-ty-kate commented 3 years ago

it looks like a similar issue than: https://github.com/ocaml/opam/issues/3650

Is it the same problem?

raphaelrk commented 3 years ago

@kit-ty-kate I'm not sure - I ran brew unlink binutils but am still running into these issues

kit-ty-kate commented 3 years ago

Could you post the output of env ?

raphaelrk commented 3 years ago

Relevant env output:

CAML_LD_LIBRARY_PATH=/Users/raphaelrk/.opam/4.12.0/lib/stublibs:/usr/local/lib/ocaml/stublibs:/usr/local/lib/ocaml
OCAML_TOPLEVEL_PATH=/Users/raphaelrk/.opam/4.12.0/lib/toplevel
OPAMNOENVNOTICE=true
OPAM_SWITCH_PREFIX=/Users/raphaelrk/.opam/4.12.0
PATH=/Users/raphaelrk/.opam/4.12.0/bin:/Users/raphaelrk/.pyenv/shims:/Users/raphaelrk/.pyenv/bin:/Users/raphaelrk/Library/Android/sdk/platform-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Genymotion.app/Contents/MacOS/tools/:/opt/X11/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/Users/raphaelrk/opt/miniconda3/bin
PKG_CONFIG_PATH=/Users/raphaelrk/.opam/4.12.0/lib/pkgconfig:
SHELL=/usr/local/bin/fish
SHLVL=1
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=440
USER=raphaelrk
__CFBundleIdentifier=com.apple.Terminal
__fish_bin_dir=/usr/local/Cellar/fish/2.2.0/bin
__fish_datadir=/usr/local/Cellar/fish/2.2.0/share/fish
__fish_help_dir=/usr/local/Cellar/fish/2.2.0/share/doc/fish
__fish_sysconfdir=/usr/local/Cellar/fish/2.2.0/etc/fish
raphaelrk commented 3 years ago

Got menhir (another library I was having issues with) to install by running brew install menhir which may be a clue - brew formula page. Unfortunately no existing brew formulae for utop / merlin / graphics.

dbuenzli commented 3 years ago

What do type ranlib and type ld return in your terminal ?

raphaelrk commented 3 years ago

@dbuenzli

~> type ranlib
ranlib is /usr/bin/ranlib
~> type ld
ld is /usr/bin/ld
dbuenzli commented 3 years ago

I don't really know what's happenning. Check that your cc is also in /usr/bin. Other than that maybe try to opam switch remove the switch and start over.

raphaelrk commented 2 years ago

Removing the switch and starting with a fresh one fixed the issue for me!