DUNE-DIAGNOSTICS(1)
π DUNE-DIAGNOSTICS(1) π
okay so this is part 1 of the Dune Manual, section 1, and we're talking about dune-diagnostics today bestie, get comfy πΈ
π NAME π
dune-diagnostics β fetch and return errors from the current build. it is literally the error-gossip channel of your build. she's giving "tell me everything that went wrong, no filter" β¨
π SYNOPSIS π
dune diagnostics [OPTION]β¦
π OPTIONS π
okay this is the big one, stay with me π«Ά
--action-stderr-on-success=VALβ same vibe as--action-stdout-on-success, but for standard error instead of standard output. and ngl, if you're in a big mono-repo, the truly iconic combo is--action-stdout-on-success=swallowplus--action-stderr-on-success=must-be-empty, because that way a successful build gets a totally clean, empty output. chef's kiss π--action-stdout-on-success=VALβ tells Dune how to treat an action's standard output when the action succeeds. the possible values are:print, which just, y'know, prints it to Dune's output;swallow, which ignores it entirely; andmust-be-empty, which literally enforces that the action printed nothing. withmust-be-empty, if the action printed anything to stdout, Dune is gonna treat that action as failed, periodt. the default isprint.--build-infoβ show build information. slay β¨--display-separate-messagesβ put a blank line between error messages so they stop holding hands. separation era π--error-reporting=VAL(absent=deterministic) β controls when build errors get reported:earlyreports them the second they're discovered,deterministicwaits until the end of the build and reports them in a deterministic order,twicedoes both: reports each error once immediately when it's discovered, and then again at the end of the build in a deterministic order. main character behavior, honestly π
-f,--forceβ force actions tied to aliases to be re-executed even when their dependencies haven't changed. she does not care about your caching today π₯--file-watcher=VAL(absent=automatic) β the mechanism for spotting changes in the source.automaticmakes Dune run an external program to detect changes.manualmeans you notify Dune that files changed, by hand, yourself. π--passive-watch-modeβ like--watchbut chiller: it only starts a build when something externally tells it to via an RPC. she's waiting for a text back π«Ά--sandbox=VAL(absentDUNE_SANDBOXenv) β set the sandboxing mode. heads up: some actions require a certain sandboxing mode and will straight-up ignore this setting. the allowed values arenone,symlink,copyandhardlink.--stop-on-first-errorβ stop the whole build the moment an error shows up. no mercy, no cap π-w,--watchβ instead of dipping after the build finishes, just keep waiting forever for file changes. girl is committed π--wait-for-filesystem-clockβ Dune digests file contents for better incrementality, and those digests get cached. sometimes Dune has to drop some digest cache entries to keep things reliable, and this option makes Dune wait for the file system clock to move forward so it doesn't have to drop anything. honestly? you probably shouldn't care about this option. it's mostly for Dune developers trying to make Dune's digest-cache tests more reproducible. iykyk π§
πΈ COMMON OPTIONS πΈ
the classics, the staples, the ones that show up everywhere π
--always-show-command-lineβ always show the full command lines of the programs Dune executes.--auto-promoteβ automatically promote files. basically like runningdune promoteright after the build. she promotes herself π--build-dir=FILE(absentDUNE_BUILD_DIRenv) β specify the build directory. it's_buildif you don't say anything.--cache=VAL(absentDUNE_CACHEenv) β turn the Dune cache on or off. one ofdisabled,enabled-except-user-rulesorenabled. the default isenabled-except-user-rules.--cache-check-probability=VAL(absentDUNE_CACHE_CHECK_PROBABILITYenv) β check build reproducibility by re-executing randomly chosen rules and comparing their results with what's stored in the Dune cache. note: raising the probability of these checks slows your build down, so be mindful. the default probability is zero, meaning no rules get checked at all.--cache-storage-mode=VAL(absentDUNE_CACHE_STORAGE_MODEenv) β the Dune cache storage mode, one ofauto,hardlinkorcopy. the default ishardlink.--config-file=FILEβ load this config file instead of the default one.--debug-backtracesβ always print exception backtraces. for when you need the full lore π--debug-dependency-pathβ when there's an error, print the dependency path from the targets on the command line all the way to the rule that failed.--debug-package-logs(absentDUNE_DEBUG_PACKAGE_LOGSenv) β always print the standard logs when building packages.--default-target=TARGET(absent=@@default) β set the default target that gets used when you don't specify one todune build.--diff-command=VAL(absentDUNE_DIFF_COMMANDenv) β the shell command to use for diffing files. use-to disable printing the diff entirely.--disable-promotion(absentDUNE_DISABLE_PROMOTIONenv) β disable all promotion rules. none of that here π«--display=MODEβ control Dune's display mode. seedune-config(5)for the details. the valid values for this option areprogress,verbose,short,quietortui.--dump-gc-stats=FILEβ dump the garbage collector stats into a file once the build is complete.--help[=FMT](default=auto) β show this help in formatFMT.FMThas to be one ofauto,pager,grofforplain. withauto, the format ends up beingpagerorplainwhenever theTERMenv var isdumbor undefined.--ignore-promoted-rulesβ ignore rules with(mode promote), except the ones with(only ...). the variable%{ignoring_promoted_rules}in dune files reflects whether this option was passed or not.--instrument-with=BACKENDS(absentDUNE_INSTRUMENT_WITHenv) β enable instrumentation byBACKENDS.BACKENDSis a comma-separated list of library names, and every single one of them has to declare an instrumentation backend.-j JOBS(absentDUNE_JOBSenv) β run no more thanJOBScommands at the same time.JOBSmust be a positive integer, orautoto auto-detect the number of cores (which is the default).--no-bufferβ do not buffer the output of commands Dune executes. by default Dune buffers subcommand output to stop things interleaving when multiple commands run in parallel β but that can be a whole problem when you're debugging long-running tests. with--no-buffer, commands get 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 alongside-j 1to avoid interleaving, and also use--verboseas well, so you're sure commands get printed before they run.--no-configβ do not load the configuration file.--no-print-directoryβ suppress those "Entering directory" messages. shush π--only-packages=PACKAGESβ ignore stanzas that refer to a package not inPACKAGES.PACKAGESis a comma-separated list of package names. note that this has the same effect as deleting the relevant stanzas from your dune files, and it's mostly meant for releases. during development you probably want to build a particular<package>.installtarget instead.-p PACKAGES,--for-release-of-packages=PACKAGES(required) β shorthand for--release --pkg=disabled --only-packages PACKAGE. you must use this option in your<package>.opamfiles, so you only build what's necessary when your project has multiple packages, and so you get reproducible builds.--pkg=VALβ enable or disable package management. the default behaviour depends on whether a lock directory exists.--profile=VAL(absentDUNE_PROFILEenv) β pick the build profile, for instancedevorrelease. the default isdev.--promote-install-files[=VAL](default=true) β promote any generated<package>.installfiles into the source tree.--releaseβ put Dune into a reproducible release mode. it's a 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, and for instance you must use it in your <package>.opam files β unless you already use -p, because -p implies this option.
--require-dune-project-file[=VAL](default=true) β fail if adune-projectfile is missing.--root=DIR(absentDUNE_ROOTenv) β use this directory as the workspace root instead of guessing it. note that this option doesn't change how targets given on the command line are interpreted β it's only intended for scripts.--store-orig-source-dir(absentDUNE_STORE_ORIG_SOURCE_DIRenv) β store the original source location indune-packagemetadata.--target-exec=TOOLCHAIN=CMD(absentDUNE_TARGET_EXECenv) β a 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 is displayed to the console between rebuilds while you're in--watchmode. supported modes:preserve,clear-on-rebuild,clear-on-rebuild-and-flush-history.--trace-file=FILEβ output trace data in catapult format (compatible withchrome://tracing).--verboseβ same as--display verbose.--versionβ show version information.--watch-exclusions=REGEXβ add a POSIX regular expression that excludes matching directories fromdune build --watch. you can repeat--watch-exclusionsto add multiple exclusions, and semicolons work as a separator too. if you provide no exclusions at all, then a standard set is used β but heads up: the moment you use one or more--watch-exclusions, none of the standard exclusions apply. the standard exclusions are:^_opam /_opam ^_esy /_esy ^\.#.* /\.#.* ~$ ^#[^#]*#$ /#[^#]*#$ ^4913$ /4913$ /.git /.hg :/windows--workspace=FILE(absentDUNE_WORKSPACEenv) β use this specific workspace file instead of looking one up.-x VAL(absentDUNE_CROSS_TARGETenv) β cross-compile using this toolchain.
β EXIT STATUS β
dune diagnostics exits with:
0β on success π1β if an error happened π130β if it was interrupted by a signal π
πΈ ENVIRONMENT πΈ
ok so these are the vibes the environment can hand to diagnostics before it even wakes up. Every single one of these lil guys changes how dune/diagnostics behaves, so set them in your shell, in a script, in CI, wherever β just know they're there. π
DUNE_BUILD_DIRβ the build directory you want to use. If you don't say anything, it's lowkey just_build. πDUNE_CACHEβ turn the Dune cache on or off. Pick one ofdisabled,enabled-except-user-rules, orenabled. The default isenabled-except-user-rules. β¨DUNE_CACHE_CHECK_PROBABILITYβ this one makes Dune check whether your builds are reproducible by re-running randomly chosen rules and comparing the results against what's sitting in the Dune cache. β οΈ Heads up bestie: bumping this probability up slows your build down. The default probability is zero, meaning no rules get checked at all. π’DUNE_CACHE_STORAGE_MODEβ how the Dune cache stores stuff: one ofauto,hardlink, orcopy. Default ishardlink. πΎDUNE_CROSS_TARGETβ cross-compile using this toolchain. πDUNE_DEBUG_PACKAGE_LOGSβ always print the standard logs when building packages. Loud and proud, no silence era. π’DUNE_DIFF_COMMANDβ the shell command used to diff files. Pass-if you want to disable printing the diff entirely. πDUNE_DISABLE_PROMOTIONβ disables all promotion rules. πDUNE_INSTRUMENT_WITHβ enables instrumentation with BACKENDS. BACKENDS is a comma-separated list of library names, and each one of those libraries has to declare an instrumentation backend. ποΈDUNE_JOBSβ never run more than JOBS commands at the same time. JOBS has to be a positive integer, orautoto auto-detect the number of cores β which, btw, is the default. π§΅DUNE_PROFILEβ the build profile. Unspecified meansdev, and it'sreleaseif-pis set. πDUNE_ROOTβ use this directory as the workspace root instead of letting Dune guess it. π Note that this option does not change how targets given on the command line are interpreted. It's only intended for scripts. iykykDUNE_SANDBOXβ the sandboxing mode to use by default. (see--sandbox) ποΈDUNE_STORE_ORIG_SOURCE_DIRβ store the original source location indune-packagemetadata. ποΈDUNE_TARGET_EXECβ a wrapper command for running target binaries when cross-compiling. Format:TOOLCHAIN=CMD(e.g.,'windows=wine'). π·DUNE_WORKSPACEβ use this specific workspace file instead of going off and looking one up. π
π SEE ALSO π
obviously. go read it, it's the main character of this whole franchise. π
and that's a wrap on DUNE-DIAGNOSTICS(1), bestie!! π«Ά this page ships with Dune 3.24.1 β that's the version in the footer, along with the date it was last touched, right there in the bottom corner. go forth and diagnose, you absolute legend. π¦β¨π
π¦ where this page comes from
- ubuntu stonking: ocaml-dune 3.24.1-4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms