# build dune doesn't work

**URL:** <https://discuss.ocaml.org/t/build-dune-doesnt-work/13326>\
**Category:** Ecosystem\
**Tags:** dune\
**Created:** [October 28, 2023, 7:14pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326 "2023-10-28T19:14:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [October 28, 2023, 7:14pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/1 "2023-10-28T19:14:33Z")

</div>

```auto
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
```

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [October 28, 2023, 8:21pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/2 "2023-10-28T20:21:20Z")

</div>

> [@Azat](#):
>
> `# /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`

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.

---

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [October 29, 2023, 6:05pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/4 "2023-10-29T18:05:27Z")

</div>

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [October 30, 2023, 8:49am UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/5 "2023-10-30T08:49:35Z")

</div>

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;

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [October 30, 2023, 10:24am UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/6 "2023-10-30T10:24:45Z")

</div>

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](https://github.com/ocaml/dune/pull/6515)

Maybe try to update xcode ?

---

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [October 31, 2023, 5:42am UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/7 "2023-10-31T05:42:09Z")

</div>

I’m dont use xcode  
.

---

<div class="post-metadata">

**Author:** ![soya](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/soya/32/119_2.png) [@soya](https://discuss.ocaml.org/u/soya)\
**Post date:** [October 31, 2023, 8:21am UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/8 "2023-10-31T08:21:15Z")

</div>

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

```auto
ls -l /Library/Developer/CommandLineTools/SDKs

```

and

```auto
 echo "" | gcc -xc - -v -E

```

---

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [October 31, 2023, 12:24pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/9 "2023-10-31T12:24:02Z")

</div>

```auto
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

```

---

<div class="post-metadata">

**Author:** ![soya](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/soya/32/119_2.png) [@soya](https://discuss.ocaml.org/u/soya)\
**Post date:** [October 31, 2023, 4:01pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/10 "2023-10-31T16:01:58Z")

</div>

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:

```auto
brew doctor

```

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

---

<div class="post-metadata">

**Author:** ![Azat](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Azat](https://discuss.ocaml.org/u/Azat)\
**Post date:** [November 3, 2023, 5:20pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/11 "2023-11-03T17:20:31Z")

</div>

> **[Xcode Command Line Tools Installation FAQ](https://www.godo.dev/tutorials/xcode-command-line-tools-installation-faq/)**
>
> How to install, update, and uninstall Xcode command line tools on macOS

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

---

<div class="post-metadata">

**Author:** ![XVilka](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvilka/32/5334_2.png) [@XVilka](https://discuss.ocaml.org/u/XVilka)\
**Post date:** [November 10, 2024, 1:54pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/12 "2024-11-10T13:54:33Z")

</div>

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:

```auto
$ 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

```

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [November 10, 2024, 2:21pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/13 "2024-11-10T14:21:40Z")

</div>

Likely an issue related to [`zstd` directory not found after updating the library · Issue #12431 · ocaml/ocaml · GitHub](https://github.com/ocaml/ocaml/issues/12431)

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

---

<div class="post-metadata">

**Author:** ![XVilka](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvilka/32/5334_2.png) [@XVilka](https://discuss.ocaml.org/u/XVilka)\
**Post date:** [November 10, 2024, 4:00pm UTC](https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/14 "2024-11-10T16:00:12Z")

</div>

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