DUNE-CLEAN(1)
π DUNE-CLEAN(1) π
okay bestie, welcome to Dune Manual β this is the page for dune-clean, and it's giving certified classics only. no cap.
β¨ NAME β¨
dune-clean β Clean the project. that's it. that's the whole job. she cleans. π
β¨ SYNOPSIS β¨
dune clean [OPTION]β¦ [PATH]β¦
π§Ή DESCRIPTION π§Ή
She removes the files that dune added, namely _build, <package>.install, and .merlin. bye bye besties π¦
And if you pass one or more PATH arguments? Then she only removes those paths from the build directory. selective queen behavior, we love to see it.
πΈ OPTIONS πΈ
--action-stderr-on-success=VALβ bestie this is literally the same as--action-stdout-on-successbut for standard error instead of standard output. A really good default for big ol' mono-repositories is--action-stdout-on-success=swallowplus--action-stderr-on-success=must-be-empty. Why? Because that combo makes sure a successful build has a "clean" empty output. iconic, honestly. β¨--action-stdout-on-success=VALβ tells dune how to handle the standard output of actions when they succeed. the possible values are:print(just print it to Dune's output),swallow(completely ignore it), andmust-be-empty(enforce that the action printed absolutely nothing). heads up: withmust-be-empty, Dune will consider the action failed if it printed anything to its standard output. the default isprint.--build-infoβ show build information. receipts, basically. π§Ύ--display-separate-messagesβ separates error messages with a blank line. breathing room for the drama.--error-reporting=VAL(absent=deterministic) β controls when build errors get reported.earlyreports errors as soon as they're discovered.deterministicreports errors at the end of the build in a deterministic order.twicereports each error twice: once as soon as it's discovered, and then again at the end of the build, in a deterministic order. not me choosingtwicefor maximum chaos π-f,--forceβ forces actions associated to aliases to be re-executed even if their dependencies haven't changed. she's not waiting for permission. periodt.--file-watcher=VAL(absent=automatic) β the mechanism for detecting changes in the source.automaticmakes dune run an external program to detect changes.manualmeans you notify dune that files have changed manually. iykyk.--passive-watch-modeβ similar to--watch, but she only starts a build when instructed externally by an RPC. lowkey the introvert of watch modes.--sandbox=VAL(absentDUNE_SANDBOXenv) β sets the sandboxing mode. FYI, some actions require a certain sandboxing mode, so they'll straight-up ignore this setting. the allowed values are:none,symlink,copy,hardlink. pick your fighter. π₯--stop-on-first-errorβ stops the build as soon as an error is encountered. no dragging it out, we respect the boundaries.-w,--watchβ instead of terminating the build after completion, she waits continuously for file changes. main character energy that never leaves the party. π--wait-for-filesystem-clockβ okay so Dune digests file contents for better incrementality, and those digests are themselves cached. sometimes Dune needs to drop some digest cache entries so things stay reliable. this option makes Dune wait for the file system clock to advance so that it doesn't need to drop anything. you should probably not care about this option ngl; it's mostly useful for Dune developers to make Dune tests of the digest cache more reproducible. dev-only tea. π΅
π COMMON OPTIONS π
these options are common to all commands. yes, every single one. she's generous like that.
--always-show-command-lineβ always show the full command lines of programs executed by dune. full transparency, no secrets in this group chat.--auto-promoteβ automatically promote files. this is similar to runningdune promoteafter the build. she does it for you, bestie.--build-dir=FILE(absentDUNE_BUILD_DIRenv) β specified build directory._buildif unspecified.--cache=VAL(absentDUNE_CACHEenv) β enable or disable Dune cache (one ofdisabled,enabled-except-user-rulesorenabled). default isenabled-except-user-rules.--cache-check-probability=VAL(absentDUNE_CACHE_CHECK_PROBABILITYenv) β checks 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. so by default she's not doing all that. π--cache-storage-mode=VAL(absentDUNE_CACHE_STORAGE_MODEenv) β Dune cache storage mode (one ofauto,hardlinkorcopy). default ishardlink.--config-file=FILEβ load this configuration file instead of the default one.--debug-backtracesβ always print exception backtraces. for when you need the full lore.--debug-dependency-pathβ in case of error, print the dependency path from the targets on the command line to the rule that failed. the paper trail. π--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's used when none is specified todune build.--diff-command=VAL(absentDUNE_DIFF_COMMANDenv) β shell command to use to diff files. use-to disable printing the diff.--disable-promotion(absentDUNE_DISABLE_PROMOTIONenv) β disable all promotion rules.--display=MODEβ controls the display mode of Dune. seedune-config(5)for more details. valid values for this option areprogress,verbose,short,quietortui.--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 formatFMT. the valueFMTmust be one ofauto,pager,grofforplain. withauto, the format ispagerorplainwhenever theTERMenv var isdumbor 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(absentDUNE_INSTRUMENT_WITHenv) β enable instrumentation byBACKENDS.BACKENDSis a comma-separated list of library names, each one of which must declare an instrumentation backend.-j JOBS(absentDUNE_JOBSenv) β run no more thanJOBScommands simultaneously.JOBSmust be a positive integer orautoto auto-detect the number of cores (the default). let her cook. π³--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. FYI, 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--verboseas well, to make sure that commands are printed before they're being executed. it's giving β¨committed to the bitβ¨.--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's not inPACKAGES.PACKAGESis a comma-separated list of package names. note that this has the same effect as deleting the relevant stanzas from dune files. it's mostly meant for releases. during development, it's likely that what you actually want instead is to build a particular<package>.installtarget.-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, in order to build only what's necessary when your project contains multiple packages, as well as getting reproducible builds. not optional, bestie, it says required. π«Ά--pkg=VALβ enable or disable package management. the default behaviour depends on whether a lock directory exists.--profile=VAL(absentDUNE_PROFILEenv) β select the build profile, for instancedevorrelease. the default isdev.--promote-install-files[=VAL](default=true) β promote any generated<package>.installfiles 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>.opamfiles. except if you already use-p, since-pimplies this option.--require-dune-project-file[=VAL](default=true) β fail if adune-projectfile is missing.--root=DIR(absentDUNE_ROOTenv) β 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's only intended for scripts.--store-orig-source-dir(absentDUNE_STORE_ORIG_SOURCE_DIRenv) β store original source location indune-packagemetadata.--target-exec=TOOLCHAIN=CMD(absentDUNE_TARGET_EXECenv) β 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 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β adds a POSIX regular expression that will exclude matching directories fromdune build --watch. the option--watch-exclusionscan be repeated to add multiple exclusions. semicolons can also be used as a separator. if no exclusions are provided, then a standard set of exclusions is used; however, if one or more--watch-exclusionsare used, none of the standard exclusions are used. the standard exclusions are:^_opam/_opam^_esy/_esy^\.#.*/\.#.*~$^#[^#]*#$/#[^#]*#$^4913$/4913$/.git/.hg:/windows. that's a whole list, she came prepared. π--workspace=FILE(absentDUNE_WORKSPACEenv) β use this specific workspace file instead of looking it up.-x VAL(absentDUNE_CROSS_TARGETenv) β cross-compile using this toolchain.
π MORE HELP π
Use dune COMMAND --help for help on a single command. she's got range, bestie.
π EXIT STATUS π
dune clean exits with:
0β on success.1β if an error happened.130β if it was interrupted by a signal.
β¦and that's part 1 of this whole saga. more on the way, don't go anywhere π
bestie we're in the env-var zone now π this is where clean looks around at your shell and goes "okay what are we working with". Every one of these changes what happens. Read them, don't skip them, i'm begging π«Ά
π Environment Variables That Actually Affect clean π
DUNE_BUILD_DIRβ the build directory you want. If you don't say anything, it's just_build, the classic.DUNE_CACHEβ turn the Dune cache on or off. Pick one ofdisabled,enabled-except-user-rulesorenabled. The default isenabled-except-user-rules(yes, that whole mouthful, it's iconic, don't question it π ).DUNE_CACHE_CHECK_PROBABILITYβ this one checks whether your builds are reproducible by re-running randomly chosen rules and comparing what comes out to what's chillin' in the Dune cache. Heads up though: the higher you crank this probability, the slower your build gets. Default probability is zero, which means literally nothing gets checked. No rules, no vibes, no re-runs πΈDUNE_CACHE_STORAGE_MODEβ how the Dune cache stores its stuff, one ofauto,hardlinkorcopy. Default ishardlink.DUNE_CROSS_TARGETβ cross-compile using this toolchain, periodt.DUNE_DEBUG_PACKAGE_LOGSβ always print the standard logs while building packages. Always. No hiding πDUNE_DIFF_COMMANDβ the shell command used to diff files. Set it to-and diff-printing gets disabled entirely.DUNE_DISABLE_PROMOTIONβ kills all promotion rules. Every single one πDUNE_INSTRUMENT_WITHβ enables instrumentation via BACKENDS, where BACKENDS is a comma-separated list of library names. And each one of those libraries has to declare an instrumentation backend, that's the whole deal.DUNE_JOBSβ never run more than JOBS commands at the same time. JOBS has to be a positive integer, orautoto auto-detect your number of cores (andautois the default, because of course it is β¨).DUNE_PROFILEβ the build profile. It'sdevif you don't specify anything, orreleaseif-pis set.DUNE_ROOTβ use this directory as the workspace root instead of letting Dune guess it. Two things though, bestie: this does not change how targets given on the command line are interpreted, and it is only intended for scripts. Scripts only. Not you, not your friend, not your dog πDUNE_SANDBOXβ the sandboxing mode used by default. (go look at--sandboxfor the deets)DUNE_STORE_ORIG_SOURCE_DIRβ stores the original source location insidedune-packagemetadata.DUNE_TARGET_EXECβ a wrapper command for running target binaries when cross-compiling. Format isTOOLCHAIN=CMD(so like,'windows=wine', that's the vibe).DUNE_WORKSPACEβ use this specific workspace file instead of Dune going on a little hunt looking it up π
π BUGS π
Got beef? Found something cursed? Take it to the issue tracker: https://github.com/ocaml/dune/issues β the devs want to hear it, fr fr.
π SEE ALSO π
okay that's the whole page, you made it, i'm so proud of you π this was DUNE-CLEAN(1) from Dune 3.24.1 β go clean some builds, you absolute main character ππ
π¦ 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