DUNE-TOP(1)

πŸ’– DUNE-TOP(1) πŸ’–

okay bestie. so you found yourself in the Dune Manual and this lil page is DUNE-TOP β€” the one that spits out toplevel directives. buckle up, we're going shopping for directives. πŸ›οΈβœ¨


🌸 NAME 🌸

dune-top β€” print a list of toplevel directives for including directories and loading cma files. that's it. that's the whole vibe. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

dune top [OPTION]… [DIR]

πŸŽ€ DESCRIPTION πŸŽ€

Print a list of toplevel directives for including directories and loading cma files. like, that's the job. no notes. πŸ‘‘

The output of dune ocaml top should be evaluated in a toplevel to make the libraries available there. so you don't just stare at it, bestie, you feed it to your toplevel. 🧚

In many toplevels this can be achieved by using the #use_output command, e.g.:

#use_output "dune ocaml top"

slay. that's literally the entire move. πŸ’–


✨ OPTIONS ✨

  • --action-stderr-on-success=VAL β€” same as --action-stdout-on-success but for standard error instead of standard output. ngl a genuinely good default for large mono-repos is --action-stdout-on-success=swallow plus --action-stderr-on-success=must-be-empty. that combo guarantees a successful build has a "clean" empty output. immaculate. 🌈
  • --action-stdout-on-success=VAL β€” tells Dune how to handle the standard output of actions when they succeed. possible values, bestie: print (just print it to Dune's output), swallow (completely ignore it), and must-be-empty (enforce that the action printed nothing β€” with this one, Dune treats the action as failed if it printed anything to its standard output). the default is print. πŸ’«
  • --build-info β€” show build information. it's giving receipts. 🧾
  • --context=CONTEXT (absent=default) β€” select the context where to build/run top. 🏠
  • --display-separate-messages β€” separate error messages with a blank line. room to breathe, periodt. 🌸
  • --error-reporting=VAL (absent=deterministic) β€” controls when build errors get reported. early reports errors as soon as they're discovered. deterministic reports errors at the end of the build in a deterministic order. twice reports each error twice: once as soon as it's discovered, and then again at the end of the build, in a deterministic order. choose your fighter. πŸ”₯
  • -f, --force β€” force actions associated to aliases to be re-executed even if their dependencies haven't changed. no cap, it just does it anyway. πŸ’ͺ
  • --file-watcher=VAL (absent=automatic) β€” the mechanism to detect changes in the source. automatic makes dune run an external program to detect changes. manual means you notify dune that files have changed manually. πŸ‘€
  • --passive-watch-mode β€” similar to [--watch], but it only starts a build when instructed externally by an RPC. it waits to be told. lowkey iconic. πŸ™ˆ
  • --sandbox=VAL (absent DUNE_SANDBOX env) β€” set the sandboxing mode. some actions require a certain sandboxing mode, so they will ignore this setting. allowed values are: none, symlink, copy, hardlink. 🧊
  • --stop-on-first-error β€” stop the build as soon as an error is encountered. no second chances, we're done here. βœ‹
  • -w, --watch β€” instead of terminating the build after completion, wait continuously for file changes. it just. keeps. watching. πŸ‘οΈπŸ‘„πŸ‘οΈ
  • --wait-for-filesystem-clock β€” Dune digests file contents for better incremental builds, and these digests are themselves cached. in some cases, Dune needs to drop some digest cache entries in order for things to be reliable. this option makes Dune wait for the filesystem clock to advance so it doesn't need to drop anything. you should probably not care about this option β€” it's mostly useful for Dune developers to make Dune tests of the digest cache more reproducible. πŸ•°οΈβœ¨

πŸ’œ COMMON OPTIONS πŸ’œ

these options are common to all commands. like, the whole family. 🫢

  • --always-show-command-line β€” always show the full command lines of programs executed by dune. πŸ“œ
  • --auto-promote β€” automatically promote files. this is similar to running dune promote after the build. πŸ’«
  • --build-dir=FILE (absent DUNE_BUILD_DIR env) β€” specified build directory. _build if unspecified. πŸ“
  • --cache=VAL (absent DUNE_CACHE env) β€” enable or disable Dune cache (one of disabled, enabled-except-user-rules or enabled). default is enabled-except-user-rules. 🎁
  • --cache-check-probability=VAL (absent DUNE_CACHE_CHECK_PROBABILITY env) β€” check build reproducibility by re-executing randomly chosen rules and comparing their results with those stored in Dune cache. note: by increasing the probability of such checks you slow down the build. the default probability is zero, i.e. no rules are checked. 😴
  • --cache-storage-mode=VAL (absent DUNE_CACHE_STORAGE_MODE env) β€” Dune cache storage mode (one of auto, hardlink or copy). default is hardlink. πŸ—„οΈ
  • --config-file=FILE β€” load this configuration file instead of the default one. not like other configs. πŸ’…
  • --debug-backtraces β€” always print exception backtraces. πŸ”
  • --debug-dependency-path β€” in case of error, print the dependency path from the targets on the command line to the rule that failed. πŸ•΅οΈ
  • --debug-package-logs (absent DUNE_DEBUG_PACKAGE_LOGS env) β€” always print the standard logs when building packages. πŸ“
  • --default-target=TARGET (absent=@@default) β€” set the default target that is used when none is specified to dune build. 🎯
  • --diff-command=VAL (absent DUNE_DIFF_COMMAND env) β€” shell command to use to diff files. use - to disable printing the diff. πŸ”€
  • --disable-promotion (absent DUNE_DISABLE_PROMOTION env) β€” disable all promotion rules. 🚫
  • --display=MODE β€” control the display mode of Dune. see dune-config(5) for more details. valid values for this option are progress, verbose, short, quiet or tui. πŸ“Ί
  • --dump-gc-stats=FILE β€” dump the garbage collector stats to a file after the build is complete. πŸ—‘οΈβœ¨
  • --help[=FMT] (default=auto) β€” show this help in format FMT. the value FMT must be one of auto, pager, groff or plain. with auto, the format is pager or plain whenever the TERM env var is dumb or undefined. πŸ™‹
  • --ignore-promoted-rules β€” ignore rules with (mode promote), except ones with (only ...). the variable %{ignoring_promoted_rules} in dune files reflects whether this option was passed or not. πŸ«₯
  • --instrument-with=BACKENDS (absent DUNE_INSTRUMENT_WITH env) β€” enable instrumentation by BACKENDS. BACKENDS is a comma-separated list of library names, each one of which must declare an instrumentation backend. πŸŽ›οΈ
  • -j JOBS (absent DUNE_JOBS env) β€” run no more than JOBS commands simultaneously. JOBS must be a positive integer or auto to auto-detect the number of cores (the default). 🧡
  • --no-buffer β€” do not buffer the output of commands executed by dune. by default dune buffers the output of subcommands, in order to prevent interleaving when multiple commands are executed in parallel. however, this can be an issue when debugging long running tests. with --no-buffer, commands have direct access to the terminal. note that as a result their output won't be captured in the log file. you should use this option in conjunction with -j 1, to avoid interleaving. additionally you should use --verbose as well, to make sure that commands are printed before they are being executed. 🚰
  • --no-config β€” do not load the configuration file. πŸ™…
  • --no-print-directory β€” suppress "Entering directory" messages. 🀫
  • --only-packages=PACKAGES β€” ignore stanzas referring to a package that is not in PACKAGES. PACKAGES is a comma-separated list of package names. note that this has the same effect as deleting the relevant stanzas from dune files. it is mostly meant for releases. during development, it is likely that what you want instead is to build a particular <package>.install target. πŸ“¦
  • -p PACKAGES, --for-release-of-packages=PACKAGES (required) β€” shorthand for --release --pkg=disabled --only-packages PACKAGE. you must use this option in your <package>.opam files, in order to build only what's necessary when your project contains multiple packages as well as getting reproducible builds. ⚠️ required, bestie, don't skip it.
  • --pkg=VAL β€” enable or disable package management. the default behaviour depends on whether a lock directory exists. πŸ”
  • --profile=VAL (absent DUNE_PROFILE env) β€” select the build profile, for instance dev or release. the default is dev. 🎭
  • --promote-install-files[=VAL] (default=true) β€” promote any generated <package>.install files to the source tree. πŸ“€
  • --release β€” put dune into a reproducible release mode. shorthand for --root . --ignore-promoted-rules --no-config --profile release --always-show-command-line --promote-install-files --require-dune-project-file --default-target @install. you should use this option for release builds. for instance, you must use this option in your <package>.opam files. except if you already use -p, as -p implies this option. πŸš€
  • --require-dune-project-file[=VAL] (default=true) β€” fail if a dune-project file is missing. 🚨
  • --root=DIR (absent DUNE_ROOT env) β€” use this directory as workspace root instead of guessing it. note that this option doesn't change the interpretation of targets given on the command line. it is only intended for scripts. 🌳
  • --store-orig-source-dir (absent DUNE_STORE_ORIG_SOURCE_DIR env) β€” store original source location in dune-package metadata. πŸ—‚οΈ
  • --target-exec=TOOLCHAIN=CMD (absent DUNE_TARGET_EXEC env) β€” wrapper command for running target binaries when cross-compiling. format: TOOLCHAIN=CMD (e.g., 'windows=wine'). 🍷
  • --terminal-persistence=MODE β€” change how the log of build results are displayed to the console between rebuilds while in --watch mode. supported modes: preserve, clear-on-rebuild, clear-on-rebuild-and-flush-history. πŸ–₯️
  • --trace-file=FILE β€” output trace data in catapult format (compatible with chrome://tracing). πŸ“Š
  • --verbose β€” same as --display verbose. πŸ—£οΈ
  • --version β€” show version information. 🏷️
  • --watch-exclusions=REGEX β€” adds a POSIX regular expression that will exclude matching directories from dune build --watch. the option --watch-exclusions can be repeated to add multiple exclusions. semicolons can be also used as a separator. if no exclusions are provided, then a standard set of exclusions is used; however, if one or more --watch-exclusions are used, none of the standard exclusions are used. the standard exclusions are: ^_opam /_opam ^_esy /_esy ^\.#.* /\.#.* ~$ ^#[^#]*#$ /#[^#]*#$ ^4913$ /4913$ /.git /.hg :/windows. 🚧
  • --workspace=FILE (absent DUNE_WORKSPACE env) β€” use this specific workspace file instead of looking it up. πŸ“„
  • -x VAL (absent DUNE_CROSS_TARGET env) β€” cross-compile using this toolchain. 🌍

🫢 MORE HELP 🫢

Use dune COMMAND --help for help on a single command. one command at a time, we love a focused queen. πŸ‘‘


⭐ EXIT STATUS ⭐

dune top exits with:

  1. 0 β€” on success. we love to see it. πŸŽ‰
  2. 1 β€” if an error happened. 😭
  3. 130 β€” if it was interrupted by a signal. πŸ’€

bestie there's more coming β€” part 2 is right behind this one, don't go anywhere πŸ’–

🌸 ENVIRONMENT 🌸

okay bestie, these are the little environment variables that change how top… wait, no, how dune behaves when you run it πŸ’– they're like the settings your terminal hands over before you even say a word. Set them in your shell, in your CI, wherever β€” they all affect the execution of top. Yes, the manpage says top. We're just keeping it real. ✨

  • DUNE_BUILD_DIR β€” the build directory you want, periodt. If you don't say anything, it's _build and that's that πŸ’…
  • DUNE_CACHE β€” turns the Dune cache on or off, and it takes one of disabled, enabled-except-user-rules or enabled. The default is enabled-except-user-rules. Like… she has opinions, but she's reasonable πŸŽ€
  • DUNE_CACHE_CHECK_PROBABILITY β€” checks whether your build is actually reproducible by re-running randomly chosen rules and comparing their results to the ones already chilling in the Dune cache πŸ¦‹. Warning bestie: bumping this probability up slows your build down. The default probability is zero, meaning no rules get checked at all. Zero. None. Living free 😌
  • DUNE_CACHE_STORAGE_MODE β€” the storage mode the Dune cache uses, one of auto, hardlink or copy. Default is hardlink. Linky link πŸ”—
  • DUNE_CROSS_TARGET β€” cross-compile using this toolchain πŸ› οΈ
  • DUNE_DEBUG_PACKAGE_LOGS β€” always print the standard logs when building packages. Not sometimes. Always. The logs are the moment and she will not hide them πŸ“’
  • DUNE_DIFF_COMMAND β€” the shell command used to diff files. Pass - if you want to disable printing the diff entirely. Use - if the diff is giving too much πŸ™ˆ
  • DUNE_DISABLE_PROMOTION β€” disables all promotion rules. Every single one. Bye πŸ‘‹
  • DUNE_INSTRUMENT_WITH β€” enables instrumentation by BACKENDS. BACKENDS is a comma-separated list of library names, and each one of those libraries has to declare an instrumentation backend. No backend declaration, no entry 🚫
  • DUNE_JOBS β€” run no more than JOBS commands at the same time. JOBS has to be a positive integer, or auto to auto-detect the number of cores (that's the default). Casual parallel slay πŸ”₯
  • DUNE_PROFILE β€” the build profile. It's dev if nothing is specified, or release if -p is set 🎚️
  • DUNE_ROOT β€” use this directory as the workspace root instead of letting dune guess it. Heads up though: this option doesn't change how targets given on the command line are interpreted, okay? It's only intended for scripts. Scripts only. Iconic but stay in your lane 🧚
  • DUNE_SANDBOX β€” the sandboxing mode to use by default. (see --sandbox) πŸ–οΈ
  • DUNE_STORE_ORIG_SOURCE_DIR β€” stores the original source location in dune-package metadata. Memory unlocked πŸ“
  • DUNE_TARGET_EXEC β€” a wrapper command for running target binaries when cross-compiling. Format is TOOLCHAIN=CMD, for example 'windows=wine' πŸ‘‘
  • DUNE_WORKSPACE β€” use this specific workspace file instead of looking it up. No hunting, no guessing, you already know her πŸ’œ

πŸ› BUGS πŸ›

Found a bug? Not the vibe, but also so valid β€” check the bug reports at https://github.com/ocaml/dune/issues and tell the maintainers everything πŸ’€πŸ«Ά


πŸ‘€ SEE ALSO πŸ‘€

  • dune(1) β€” go read her too, she's the main character πŸŽ€

and that's a wrap, bestie ✨ this was the manpage for Dune 3.24.1, the DUNE-TOP(1) page β€” go build something iconic with it. no cap, you got this πŸ’…πŸ’–πŸŒˆ

πŸ“¦ where this page comes from