build dune doesn't work

install **dune** 3.11.1

<><> **Processing actions** <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫

⬇ retrieved **dune**.3.11.1 (cached)

[ERROR] The compilation of dune.3.11.1 failed at "ocaml boot/bootstrap.ml -j 7".

#=== **ERROR** **while compiling dune.3.11.1** ========================================#

# context 2.1.5 | macos/arm64 | ocaml-variants.5.1.0+options | https://opam.ocaml.org#140a8677

# path ~/.opam/5.1.0+options/.opam-switch/build/dune.3.11.1

# command ~/.opam/opam-init/hooks/sandbox.sh build ocaml boot/bootstrap.ml -j 7

# exit-code 2

# env-file ~/.opam/log/dune-9092-9167b3.env

# output-file ~/.opam/log/dune-9092-9167b3.out

### output ###

# ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot -I +unix unix.cma boot/libs.ml boot/duneboot.ml

# ./.duneboot.exe -j 7

# cd _boot && /Users/azat/.opam/5.1.0+options/bin/ocamlopt.opt -c -g -I +unix -I +threads fsevents_stubs.c

# In file included from src/fsevents/fsevents_stubs.c:16:

# In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:

# In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:

# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:176:10: fatal error: 'CarbonCore/Folders.h' file not found

# #include <CarbonCore/Folders.h>

# ^~~~~~~~~~~~~~~~~~~~~~

# 1 error generated.

#

<><> **Error report** <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫

┌─ The following actions failed

│ λ build **dune** 3.11.1

└─

╶─ No changes have been performed

This is a very strange error, from far it looks like a botched install of the macOS dev tools. I have the same kind of configuration and dune.3.11.1 installs fine. Could you maybe output the results of opam config report and env to see if there’s maybe something suspicious.

opam config report
# opam config report
# opam-version         2.1.5 
# self-upgrade         no
# system               arch=arm64 os=macos os-distribution=homebrew os-version=12.5
# 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 6ce4f1bb)
# pinned               0
# current-switch       default
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /opt/homebrew/lib/ocaml/stublibs:/opt/homebrew/lib/ocaml
# ocaml:preinstalled   true
# ocaml:compiler       system
# ocaml-system:path    /opt/homebrew/bin
OPAM_SWITCH_PREFIX='/Users/azat/.opam/5.1.0'; export OPAM_SWITCH_PREFIX;

CAML_LD_LIBRARY_PATH=‘/Users/azat/.opam/5.1.0/lib/stublibs:/Users/azat/.opam/5.1.0/lib/ocaml/stublibs:/Users/azat/.opam/5.1.0/lib/ocaml’; export CAML_LD_LIBRARY_PATH;

OCAML_TOPLEVEL_PATH=‘/Users/azat/.opam/5.1.0/lib/toplevel’; export OCAML_TOPLEVEL_PATH;

PATH=‘/Users/azat/.opam/5.1.0/bin:/Users/azat/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/azat/.nexustools’; export PATH;

Do you have C_INCLUDE_PATH set to something by any chance ?

EDIT: It seems there have been problems with compiling this file see fix: re-enable dune on older macos sdk's by rgrinberg · Pull Request #6515 · ocaml/dune · GitHub

Maybe try to update xcode ?

I’m dont use xcode
.

You need to have some kind of c compiler installed. Usually that comes with xcode on Mac. And was likely installed when you setup homebrew.
You already have xcode command line tools. (C compiler, headers etc).
Ie. the files located in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Try

ls -l /Library/Developer/CommandLineTools/SDKs

and

 echo "" | gcc -xc - -v -E
ls -l /Library/Developer/CommandLineTools/SDKs

total 0

lrwxr-xr-x 1 root wheel 14 13 ноя 2022 MacOSX.sdk -> MacOSX13.0.sdk

drwxr-xr-x 7 root wheel 224 13 ноя 2022 **MacOSX11.3.sdk**

lrwxr-xr-x 1 root wheel 14 13 ноя 2022 MacOSX11.sdk -> MacOSX11.3.sdk

drwxr-xr-x 7 root wheel 224 20 ноя 2021 **MacOSX12.1.sdk**

drwxr-xr-x 7 root wheel 224 13 ноя 2022 **MacOSX12.3.sdk**

lrwxr-xr-x 1 root wheel 14 13 ноя 2022 MacOSX12.sdk -> MacOSX12.3.sdk

drwxr-xr-x 7 root wheel 224 6 окт 2022 **MacOSX13.0.sdk**

lrwxr-xr-x 1 root wheel 14 13 ноя 2022 MacOSX13.sdk -> MacOSX13.0.sdk

**➜** **~** echo "" | gcc -xc - -v -E

Apple clang version 14.0.0 (clang-1400.0.29.202)

Target: arm64-apple-darwin21.6.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple arm64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -fno-rounding-math -funwind-tables=2 -fobjc-msgsend-selector-stubs -target-sdk-version=13.0 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp16fml -target-feature +ras -target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -fallow-half-arguments-and-returns -debugger-tuning=lldb -target-linker-version 820.1 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdebug-compilation-dir=/Users/azat -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c -

clang -cc1 version 14.0.0 (clang-1400.0.29.202) default target arm64-apple-darwin21.6.0

ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"

ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"

#include "..." search starts here:

#include <...> search starts here:

/usr/local/include

/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

/Library/Developer/CommandLineTools/usr/include

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)

End of search list.

# 1 "<stdin>"

# 1 "<built-in>" 1

# 1 "<built-in>" 3

# 400 "<built-in>" 3

# 1 "<command line>" 1

# 1 "<built-in>" 2

# 1 "<stdin>" 2

Make sure your sdk is updated too if you upgraded OSX to Catalina. I.e. check software update.

A few things to check as well:

brew doctor

Other than that I don’t have any ideas. Last resort is reinstalling Xcode command line utils client.

2 Likes

I solved my problem with the help of this site
thanks to everyone who helped

2 Likes

I met the same problem but XCode tools are installed, LLVM and Clang are present, as well as Zstd via Homebrew. But it still fails to build:

$ opam install dune-configurator
The following actions will be performed:
=== install 3 packages
  ∗ csexp             1.5.2  [required by dune-configurator]
  ∗ dune              3.16.0 [required by dune-configurator]
  ∗ dune-configurator 3.16.0

Proceed with ∗ 3 installations? [y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
Processing  1/8: [csexp.1.5.2: extract]
⬇ retrieved csexp.1.5.2  (cached)
⬇ retrieved dune.3.16.0, dune-configurator.3.16.0  (cached)
[ERROR] The compilation of dune.3.16.0 failed at "ocaml boot/bootstrap.ml -j 9".

#=== ERROR while compiling dune.3.16.0 ========================================#
# context     2.2.1 | macos/arm64 | ocaml-system.5.2.0 | https://opam.ocaml.org#f11abb65
# path        ~/.opam/ocaml-system/.opam-switch/build/dune.3.16.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml boot/bootstrap.ml -j 9
# exit-code   2
# env-file    ~/.opam/log/dune-8637-27c14c.env
# output-file ~/.opam/log/dune-8637-27c14c.out
### output ###
# ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot -I +unix unix.cma boot/libs.ml boot/duneboot.ml
# ld: library 'zstd' not found
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "boot/duneboot.ml", line 1:
# Error: Error while building custom runtime system



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ λ build dune 3.16.0
└─
╶─ No changes have been performed

Likely an issue related to `zstd` directory not found after updating the library · Issue #12431 · ocaml/ocaml · GitHub

Maybe try to brew upgrade and/or make a non system switch.

1 Like

Thanks! Solved the problem, but not the way recommended in the issue - just brew reinstall ocaml opam was sufficient.

1 Like