DUNE-FMT(1)
π
DUNE-FMT(1) β aka dune-fmt, straight outta the Dune manual (section 1, bestie) π
okay so you opened a manual page, and it's about formatting your source code. no cap, this is the glow-up your OCaml is begging for. let's get into it β¨
β¨ NAME β¨
dune-fmt β format source code. that's it. that's the whole job. and it eats. π
πΈ SYNOPSIS πΈ
dune fmt [OPTION]β¦
like, you run it, you give it options, it formats. iconic. π¦
π DESCRIPTION π
so dune fmt runs the formatter on your source code. and the way it just... picks the formatter for you?? main character energy fr fr. you don't have to choose, it already knows:
ocamlformatgets used for OCaml source code β that's your*.mland*.mlifiles π§refmtgets used for Reason source code β that's your*.reand*.reifiles π
so it looks at what you wrote, and it handles it. slay. no cap. π
π₯ OPTIONS π₯
--action-stderr-on-success=VALβ literally the same as--action-stdout-on-successbut for standard error instead of standard output. and ngl, a really good default for large mono-repositories is--action-stdout-on-success=swallowplus--action-stderr-on-success=must-be-empty. that combo means a successful build has a "clean" empty output. chef's kiss. π--action-stdout-on-success=VALβ tells Dune how to deal with an action's standard output when that action succeeds. the possible values are:printβ just print it to Dune's outputswallowβ completely ignore itmust-be-emptyβ enforce that the action printed nothing at all
and with must-be-empty, Dune will consider the action failed if it printed anything to standard output. π the default is print.
--build-infoβ show build information. π--display-separate-messagesβ separates error messages with a blank line. breathing room bestie πΈ--error-reporting=VAL(absent=deterministic) β controls when build errors get reported. the options are:earlyβ reports errors as soon as they are discovereddeterministicβ reports errors at the end of the build, in a deterministic ordertwiceβ reports each error twice: once as soon as it's discovered, and then again at the end of the build, in a deterministic order
two-for-one, kinda obsessed π«Ά
-f,--forceβ force actions associated with aliases to be re-executed even if their dependencies haven't changed. it's giving "I do what I want." π--file-watcher=VAL(absent=automatic) β the mechanism used to detect changes in the source.automaticmakes dune run an external program to detect changes.manualmeans you notify dune that files have changed manually. π¦--passive-watch-modeβ similar to--watch, but it only starts a build when it's instructed externally by an RPC. it just sits there, waiting for the group chat to ping it π--previewβ just prints the changes that would be made, without actually applying them. and heads up: this takes precedence overauto-promote, because that flag is assumed for this command. π--sandbox=VAL(absentDUNE_SANDBOXenv) β sets the sandboxing mode. some actions require a certain sandboxing mode, so they'll ignore this setting. allowed values:none,symlink,copy,hardlink. π§--stop-on-first-errorβ stops the build the second it hits an error. dramatic exit, love that for it π-w,--watchβ instead of terminating the build after completion, it waits continuously for file changes. it's got main character energy and it's not leaving the party π--wait-for-filesystem-clockβ ok so Dune digests file contents for better incrementality, and those digests are themselves cached. in some cases Dune needs to drop some digest cache entries for things to be reliable. this option makes Dune wait for the file system 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. yes, all of them. equal opportunity flags β¨
--always-show-command-lineβ always show the full command lines of programs executed by dune. full transparency, we love to see it π--auto-promoteβ automatically promote files. this is similar to runningdune promoteafter the build. π¦--build-dir=FILE(absentDUNE_BUILD_DIRenv) β specified build directory. it's_buildif unspecified. π--cache=VAL(absentDUNE_CACHEenv) β enable or disable Dune cache. 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 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 like, zero is free. π--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. π--debug-dependency-pathβ in case of error, print the dependency path from the targets on the command line to the rule that failed. follow the crime scene tape π¨--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 is 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β control the display mode of Dune. seedune-config(5)for more details. valid values for this option areprogress,verbose,short,quietortui. pick your aesthetic π--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, and each one of them 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 (that's 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--verboseas well, to make sure that commands are printed before they are being executed. a whole little ritual, honestly π―οΈ--no-configβ do not load the configuration file. π--no-print-directoryβ suppress "Entering directory" messages. quiet luxury π--only-packages=PACKAGESβ ignore stanzas referring to a package that is 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 is mostly meant for releases. during development, it is likely that what you 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. periodt π--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, as-pimplies this option. β¨--require-dune-project-file[=VAL](default=true) β fail if adune-projectfile is missing. no file, no vibes π--root=DIR(absentDUNE_ROOTenv) β use this directory as the 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(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. wordy queen π--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
π«
--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. one command at a time, bestie, we're doing this right π
β EXIT STATUS β
dune fmt exits with:
0β on success. we love a win π1β if an error happened. it's giving unfortunate π130β if it was interrupted by a signal. π
lowkey obsessed with you for reading the docs, fr fr. more coming πβ¨
πΏ ENVIRONMENT πΏ
okay so these little environment variables? they literally change how fmt runs, bestie. set them, unset them, whatever β but know what they do first π
CLICOLORβ if this is anything other than0, then ANSI colors are supported and should be used whenever the program isn't piped. but if it's equal to0? no ANSI color escape codes for you, periodt. π¨CLICOLOR_FORCEβ if this is different than0, ANSI colors get enabled no matter what. like, it doesn't care. it said what it said. β¨DUNE_BUILD_DIRβ the build directory you want specified. and if you don't say anything? it's_build. default behavior, iconic. πDUNE_CACHEβ turn Dune cache on or off. your options are one ofdisabled,enabled-except-user-rulesorenabled. and the default? it's`enabled-except-user-rules'. that's just the vibe it ships with. πΎDUNE_CACHE_CHECK_PROBABILITYβ this one checks build reproducibility by re-executing randomly chosen rules and comparing the results against what's stored in Dune cache. β οΈ note: if you crank up the probability of these checks, you slow down the build. lowkey a tradeoff. the default probability is zero, meaning like, no rules get checked. not one. πDUNE_CACHE_ROOTβ if you set this, it determines where all the different caches thatduneuses live. one home for all of them. πDUNE_CACHE_STORAGE_MODEβ Dune cache storage mode, and it's one ofauto,hardlinkorcopy. default is`hardlink'. β¨DUNE_CROSS_TARGETβ cross-compile using this toolchain. π οΈDUNE_DEBUG_PACKAGE_LOGSβ always print the standard logs when building packages. always. every time. main character logging energy. πDUNE_DIFF_COMMANDβ the shell command to use for diffing files. and if you use-? that disables printing the diff entirely. bye diff. πDUNE_DISABLE_PROMOTIONβ disables all promotion rules. all of them. π«DUNE_INSTRUMENT_WITHβ enable instrumentation by BACKENDS. BACKENDS here is a comma-separated list of library names, and each single one of them has to declare an instrumentation backend. no backend declared, no deal. π¬DUNE_JOBSβ run no more than JOBS commands at the same time. JOBS has to be a positive integer, orautoto auto-detect the number of cores (andautois the default, bestie). βοΈDUNE_PROFILEβ the build profile. it'sdevif unspecified, orreleaseif-pis set. πΈDUNE_ROOTβ use this directory as the workspace root instead of letting it guess. π but heads up: this option does not change how targets given on the command line are interpreted. it's only intended for scripts. iykyk π«ΆDUNE_SANDBOXβ the sandboxing mode to use by default. (peep--sandboxfor more π)DUNE_STORE_ORIG_SOURCE_DIRβ stores the original source location in thedune-packagemetadata. π¦DUNE_TARGET_EXECβ wrapper command for running target binaries when cross-compiling. the format is: TOOLCHAIN=CMD (for example,'windows=wine'). π·DUNE_WORKSPACEβ use this specific workspace file instead of hunting it down. π
π BUGS π
found something cursed? check the bug reports at https://github.com/ocaml/dune/issues β that's where the receipts live, bestie π
π SEE ALSO π
dune(1)β literally go read it, it's right there π
and that's the whole page!! this was Dune 3.24.1, served up fresh as DUNE-FMT(1) β¨ mwah, go format something gorgeous π
ππ¦
π¦ 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