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-success except 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), or must-be-empty (enforce that the action printed literally nothing). With must-be-empty, if the action printed anything at all to standard output, Dune will decide the action failed. The default is print.
  • --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. early reports errors the second they're discovered. deterministic reports errors at the end of the build, in a deterministic order. twice is 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. automatic makes dune run an external program to detect changes. Manual means 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 (absent DUNE_SANDBOX env) β€” 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 running dune promote after the build. ✨
  • --build-dir=FILE (absent DUNE_BUILD_DIR env) β€” specifies the build directory. It's _build if unspecified.
  • --cache=VAL (absent DUNE_CACHE env) β€” enable or disable the 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) β€” 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 (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.
  • --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 (absent DUNE_DEBUG_PACKAGE_LOGS env) β€” always print the standard logs when building packages.
  • --default-target=TARGET (absent=@@default) β€” sets the default target used when none is specified to dune build.
  • --diff-command=VAL (absent DUNE_DIFF_COMMAND env) β€” the shell command to use for diffing files. Use - to disable printing the diff entirely.
  • --disable-promotion (absent DUNE_DISABLE_PROMOTION env) β€” disables all promotion rules. All of them. Gone. πŸ‘‹
  • --display=MODE β€” controls Dune's display mode. See dune-config(5) for more details. Valid values for this option are progress, verbose, short, quiet or tui.
  • --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 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 β€” 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 (absent DUNE_INSTRUMENT_WITH env) β€” 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 (absent DUNE_JOBS env) β€” runs no more than JOBS commands simultaneously. JOBS must be a positive integer, or auto to 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 1 to avoid interleaving, and you should also use --verbose as 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>.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, 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 (absent DUNE_PROFILE env) β€” selects the build profile, for instance dev or release. The default is dev.
  • --promote-install-files[=VAL] (default=true) β€” promotes any generated <package>.install files 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>.opam files β€” except if you already use -p, since -p implies this option anyway. πŸ‘‘
  • --require-dune-project-file[=VAL] (default=true) β€” fails if a dune-project file is missing. No dune-project? No build. πŸ’€
  • --root=DIR (absent DUNE_ROOT env) β€” 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 (absent DUNE_STORE_ORIG_SOURCE_DIR env) β€” stores the 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 β€” changes how the log of build results gets 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 β€” outputs 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, 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-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.

πŸ’€ 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 of disabled, enabled-except-user-rules or enabled. default is enabled-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 of auto, hardlink or copy. default is hardlink.
  • 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, or auto to auto-detect the number of cores (that's the default, queen behavior πŸ‘‘).
  • DUNE_PROFILE β€” the build profile. dev if you didn't specify anything, or release if -p is 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 the dune-package metadata.
  • DUNE_TARGET_EXEC β€” the wrapper command used for running target binaries when you're cross-compiling. format is TOOLCHAIN=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