DUNE-FORMAT-DUNE-FILE(1)
β¨ NAME β¨
dune-format-dune-file β it formats dune files, bestie. That's it. That's the whole job. π
(this one's from the Dune Manual, page dune-format-dune-file(1), okay so let's get into it π«Ά)
πΈ SYNOPSIS πΈ
dune format-dune-file [OPTION]β¦ [FILE]
π DESCRIPTION π
Okay so dune format-dune-file reads a dune file, and outputs a formatted version of it. That's the vibe. β¨
But lowkey listen: this is a low-level command. It's here to implement stuff like editor support, not to be your everyday bestie. So if you're trying to reformat a whole entire dune project, don't come here β go read the "Automatic formatting" section in the manual instead. iykyk. π
π ARGUMENTS π
FILEβ the path to the dune file you want parsed. Point at it, let it cook. π₯
β OPTIONS β
--action-stderr-on-success=VALβ literally the exact same as--action-stdout-on-successexcept it's for standard error instead of standard output. And ngl, if you're in a big ol' mono-repository, a genuinely good default combo is--action-stdout-on-success=swallow+--action-stderr-on-success=must-be-emptyβ that way a successful build gives you a "clean", empty output. Chef's kiss. π--action-stdout-on-success=VALβ tells Dune how to treat the standard output when actions succeed. The possible values are:print(just print it right into Dune's output),swallow(completely ignore it, pretend it never happened), ormust-be-empty(enforce that the action printed literally nothing). Withmust-be-empty, if the action printed anything at all to standard output, Dune will decide the action failed. The default isprint.--build-infoβ show build information. Receipts, basically. π§Ύ--display-separate-messagesβ puts a blank line between error messages. Breathing room, you're welcome. π¬οΈ--dune-version=VERSIONβ which version of the Dune language to use.--error-reporting=VAL(absent=deterministic) β controls when build errors get reported.earlyreports errors the second they're discovered.deterministicreports errors at the end of the build, in a deterministic order.twiceis an overachiever: it reports each error twice β once the moment it's discovered, and then again at the end of the build, in a deterministic order. π-f,--forceβ forces actions tied to aliases to be re-executed even if their dependencies haven't changed at all. No changes? Doesn't matter. Run it anyway. πͺ--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, by hand.--passive-watch-modeβ basically[--watch]'s chill sibling: it only starts a build when it's instructed externally by an RPC. It waits. Patiently. π¦--sandbox=VAL(absentDUNE_SANDBOXenv) β sets the sandboxing mode. Heads up: some actions require a certain sandboxing mode so they'll straight up ignore this setting. The allowed values are:none,symlink,copy,hardlink.--stop-on-first-errorβ the second an error shows up, the build stops. Not one more step. π-w,--watchβ instead of dipping out after the build completes, it just waits around continuously for file changes. Main character who never leaves the party. π--wait-for-filesystem-clockβ so, Dune digests file contents for better incrementality, and those digests are themselves cached. Sometimes Dune has to drop some digest cache entries for things to stay 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 who want to make Dune tests of the digest cache more reproducible. That's it, that's the whole thing. π
π COMMON OPTIONS π
--always-show-command-lineβ always show the full command lines of the programs dune executes. Full transparency, no gatekeeping. π--auto-promoteβ automatically promotes files. It's basically like runningdune promoteafter the build. β¨--build-dir=FILE(absentDUNE_BUILD_DIRenv) β specifies the build directory. It's_buildif unspecified.--cache=VAL(absentDUNE_CACHEenv) β enable or disable the 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 against what's stored in the Dune cache. β οΈ Note: by increasing the probability of these checks, you slow the build down. The default probability is zero, i.e. no rules are checked.--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. The full lore when things go wrong. π--debug-dependency-pathβ if there's an error, print the dependency path from the targets on the command line all the way to the rule that failed. Detective mode. π--debug-package-logs(absentDUNE_DEBUG_PACKAGE_LOGSenv) β always print the standard logs when building packages.--default-target=TARGET(absent=@@default) β sets the default target used when none is specified 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) β disables all promotion rules. All of them. Gone. π--display=MODEβ controls Dune's display mode. Seedune-config(5)for more details. Valid values for this option areprogress,verbose,short,quietortui.--dump-gc-stats=FILEβ dumps the garbage collector stats into a file once the build is complete.--help[=FMT](default=auto) β shows this help in format FMT. FMT must be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined.--ignore-promoted-rulesβ ignores rules with(mode promote), except ones with(only ...). The variable%{ignoring_promoted_rules}in dune files reflects whether this option was passed or not. So the dune files know. π--instrument-with=BACKENDS(absentDUNE_INSTRUMENT_WITHenv) β enables instrumentation by BACKENDS. BACKENDS is a comma-separated list of library names, and each one of them must declare an instrumentation backend.-j JOBS(absentDUNE_JOBSenv) β runs no more than JOBS commands simultaneously. JOBS must be a positive integer, orautoto auto-detect the number of cores (that's the default). π§--no-bufferβ don't buffer the output of commands executed by dune. By default dune buffers the output of subcommands, so that stuff doesn't get all interleaved when multiple commands run in parallel. But that can be a whole issue when you're debugging long-running tests. With--no-buffer, commands get direct access to the terminal. β οΈ But heads up: as a result, their output won't be captured in the log file. You should use this option together with-j 1to avoid interleaving, and you should also use--verboseas well to make sure commands are printed before they're being executed.--no-configβ do not load the configuration file.--no-print-directoryβ suppresses the "Entering directory" messages.--only-packages=PACKAGESβ ignore stanzas that refer to a package that isn't in PACKAGES. PACKAGES is a comma-separated list of package names. Note that this has the exact same effect as deleting the relevant stanzas from dune files. It's mostly meant for releases. During development, what you probably 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, so that only what's necessary gets built when your project has multiple packages β and so you get reproducible builds. No skipping this one. π₯--pkg=VALβ enable or disable package management. The default behaviour depends on whether a lock directory exists.--profile=VAL(absentDUNE_PROFILEenv) β selects the build profile, for instancedevorrelease. The default isdev.--promote-install-files[=VAL](default=true) β promotes any generated<package>.installfiles to the source tree. β¨--releaseβ puts 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, and for instance you must use this option in your<package>.opamfiles β except if you already use-p, since-pimplies this option anyway. π--require-dune-project-file[=VAL](default=true) β fails if adune-projectfile is missing. Nodune-project? No build. π--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 get interpreted β it's only intended for scripts.--store-orig-source-dir(absentDUNE_STORE_ORIG_SOURCE_DIRenv) β stores the 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β changes how the log of build results gets displayed to the console between rebuilds while in--watchmode. Supported modes:preserve,clear-on-rebuild,clear-on-rebuild-and-flush-history.--trace-file=FILEβ outputs 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, and 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.
π EXIT STATUS π
dune format-dune-file exits with:
0β on success. slay. π1β if an error happened. π130β if it was interrupted by a signal.
πΏ ENVIRONMENT πΏ
okay bestie so these environment variables are the ones that actually do stuff when you run format-dune-file. they're like the settings menu but for your shell, yk? set them, export them, vibe. β¨
DUNE_BUILD_DIRβ the build directory you're pointing at. if you don't say anything it just defaults to_build, no big deal πDUNE_CACHEβ turns the Dune cache on or off. pick one ofdisabled,enabled-except-user-rulesorenabled. default isenabled-except-user-rules, bestie.DUNE_CACHE_CHECK_PROBABILITYβ makes Dune double-check that your builds are actually reproducible, by re-running randomly chosen rules and comparing the results with what's stored in the Dune cache.
β οΈ heads up: raising this probability makes your builds slower. the default probability is zero, meaning literally no rules get checked. π
DUNE_CACHE_STORAGE_MODEβ how the Dune cache stores things. one ofauto,hardlinkorcopy. default ishardlink.DUNE_CROSS_TARGETβ cross-compile using this toolchain.DUNE_DEBUG_PACKAGE_LOGSβ always print the standard logs when building packages. πͺ΅DUNE_DIFF_COMMANDβ the shell command used to diff files. if you set it to-, printing the diff is fully off. gone. πDUNE_DISABLE_PROMOTIONβ disables all the promotion rules. all of them. periodt.DUNE_INSTRUMENT_WITHβ enables instrumentation by BACKENDS. BACKENDS is a comma-separated list of library names, and every single one of them has to declare an instrumentation backend. no slack.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 (that's the default, queen behavior π).DUNE_PROFILEβ the build profile.devif you didn't specify anything, orreleaseif-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, iykyk.DUNE_SANDBOXβ the sandboxing mode to use by default. (peep--sandboxπ«Ά)DUNE_STORE_ORIG_SOURCE_DIRβ stores the original source location in thedune-packagemetadata.DUNE_TARGET_EXECβ the wrapper command used for running target binaries when you're cross-compiling. format isTOOLCHAIN=CMD(e.g.,'windows=wine'). π·DUNE_WORKSPACEβ use this specific workspace file instead of Dune going off to look it up itself.
π SEE ALSO π
dune(1)β go read it, bestie, it's the whole ecosystem π
and that's a wrap on format-dune-file!! this page is from Dune 3.24.1 and it's the man page for DUNE-FORMAT-DUNE-FILE(1). go forth and format, you absolute icon ππ¦β
π¦ 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