DUNE-UTOP(1)

๐ŸŒˆ dune-utop(1) ๐ŸŒˆ โ€” Dune Manual vibes only โœจ

okay so. bestie. you found the manual page. it's givingโœจdocumentationโœจ and honestly? it's a lot. but we're gonna get through it together because you deserve to know what dune utop is doing. no cap. ๐Ÿ’…


๐ŸŽ€ NAME ๐ŸŽ€

dune-utop โ€” load your library up in utop, fr fr. ๐Ÿฆ‹


๐Ÿ“ SYNOPSIS ๐Ÿ“

dune utop [OPTION]โ€ฆ [DIR] [ARGS]โ€ฆ

๐Ÿ’– DESCRIPTION ๐Ÿ’–

dune utop DIR does the whole thing: it builds and then runs the utop toplevel with all the libraries that are defined in DIR. like, it hands you a toplevel pre-loaded with your own code. iconic behaviour honestly. ๐Ÿ‘‘


โœจ OPTIONS โœจ

  • --action-stderr-on-success=VAL โ€” literally the same as --action-stdout-on-success except it's for standard error instead of standard output. for big mono-repos the glow-up default is --action-stdout-on-success=swallow --action-stderr-on-success=must-be-empty. that combo guarantees a successful build has a "clean", empty output. chef's kiss. ๐Ÿงš
  • --action-stdout-on-success=VAL โ€” controls how Dune treats the standard output of actions when they succeed. the possible values are: print (just print it to Dune's output), swallow (completely ignore it), and must-be-empty (enforce that the action printed nothing โ€” with must-be-empty, Dune decides the action failed if it printed anything to its standard output ๐Ÿ˜ญ). default is print.
  • --build-info โ€” show build information. that's it, that's the option. ๐Ÿ“‹
  • --context=CONTEXT (absent=default) โ€” pick which context to build/run utop in. ๐Ÿ 
  • --display-separate-messages โ€” separate error messages with a blank line. breathing room between the chaos. ๐Ÿ˜ฎโ€๐Ÿ’จ
  • --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 reports each error twice: once the moment it's discovered, and again at the end of the build in deterministic order. yes, twice. it said what it said. ๐Ÿ’€
  • -f, --force โ€” forces actions tied to aliases to be re-executed even if their dependencies haven't changed. no take-backs. ๐Ÿ”ฅ
  • --file-watcher=VAL (absent=automatic) โ€” the mechanism for detecting changes in the source. automatic makes dune run an external program to spot changes. manual means you notify dune yourself that files changed. ๐Ÿ‘€
  • --passive-watch-mode โ€” basically --watch but chill: it only starts a build when something instructs it externally via an RPC. ๐Ÿ˜Œ
  • --sandbox=VAL (absent DUNE_SANDBOX env) โ€” sets the sandboxing mode. heads up: some actions require a certain sandboxing mode, so they'll just ignore this setting entirely (main character energy, honestly). allowed values are: none, symlink, copy, hardlink. ๐Ÿ“ฆ
  • --stop-on-first-error โ€” stop the build the absolute second an error shows up. no waiting, no collecting. ๐Ÿ’…
  • -w, --watch โ€” instead of dipping out after the build completes, it just waits around continuously for file changes. ๐Ÿ•ฐ๏ธ
  • --wait-for-filesystem-clock โ€” okay so Dune digests file contents for better incrementality, and those digests get cached. sometimes Dune has to drop some digest cache entries so everything stays 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 at all โ€” it's mostly for Dune developers, to make Dune's tests of the digest cache more reproducible. ๐Ÿงช

๐ŸŒธ COMMON OPTIONS ๐ŸŒธ

these ones are common to all commands, not just this one. โœจ

  • --always-show-command-line โ€” always show the full command lines of the programs Dune executes. full transparency, no secrets. ๐Ÿ”
  • --auto-promote โ€” automatically promote files. it's basically the same as running dune promote after the build. glow-up on autopilot. ๐Ÿ’–
  • --build-dir=FILE (absent DUNE_BUILD_DIR env) โ€” specifies the build directory. if you don't specify it? _build. ๐Ÿ“
  • --cache=VAL (absent DUNE_CACHE env) โ€” turn the Dune cache on or off. 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. โš ๏ธ heads up though: raising this probability slows your build down. default probability is zero, meaning no rules get checked at all. ๐ŸŒ
  • --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. picky, and valid for it. ๐Ÿ“„
  • --debug-backtraces โ€” always print exception backtraces. ๐Ÿ›
  • --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. follow the breadcrumbs. ๐Ÿž
  • --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 used to diff files. use - to disable printing the diff. ๐Ÿ”€
  • --disable-promotion (absent DUNE_DISABLE_PROMOTION env) โ€” disables all promotion rules. ๐Ÿšซ
  • --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 โ€” dump the garbage collector stats to a file once the build is complete. ๐Ÿ—‘๏ธ
  • --help[=FMT] (default=auto) โ€” show 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 โ€” 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 (absent DUNE_INSTRUMENT_WITH env) โ€” enable 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) โ€” run no more than JOBS commands simultaneously. JOBS must be a positive integer, or auto to auto-detect the number of cores (which is the default). ๐Ÿงต
  • --no-buffer โ€” do not buffer the output of commands executed by dune. by default dune does buffer subcommand output, so that parallel commands don't interleave into a mess. but that can be a real problem when you're debugging long running tests. with --no-buffer, commands get direct access to the terminal. โš ๏ธ but note: as a result their output won't be captured in the log file. you should use this together with -j 1 to avoid interleaving, and you should also use --verbose so commands get printed before they're executed. ๐Ÿ–จ๏ธ
  • --no-config โ€” don't load the configuration file. ๐Ÿ™…
  • --no-print-directory โ€” suppress "Entering directory" messages. shhh. ๐Ÿคซ
  • --only-packages=PACKAGES โ€” ignore stanzas that refer to a package not in PACKAGES. PACKAGES is a comma-separated list of package names. heads up: this has the same effect as deleting the relevant stanzas from dune files, and it's mostly meant for releases. during development, what you probably actually want is to build a particular <package>.install target 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>.opam files, so that only what's necessary gets built when your project contains multiple packages, and so you get reproducible builds. non-negotiable. ๐Ÿ“Œ
  • --pkg=VAL โ€” enable or disable package management. the default behaviour depends on whether a lock directory exists. ๐Ÿ”
  • --profile=VAL (absent DUNE_PROFILE env) โ€” select the build profile, for instance dev or release. default is dev. ๐ŸŽš๏ธ
  • --promote-install-files[=VAL] (default=true) โ€” promote 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 for release builds โ€” for instance, you must use it in your <package>.opam files. except if you already use -p, because -p implies this option. ๐Ÿ“ฆโœจ
  • --require-dune-project-file[=VAL] (default=true) โ€” fail if a dune-project file is missing. ๐Ÿšจ
  • --root=DIR (absent DUNE_ROOT env) โ€” 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's only intended for scripts. ๐Ÿ—‚๏ธ
  • --store-orig-source-dir (absent DUNE_STORE_ORIG_SOURCE_DIR env) โ€” store 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 is 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 โ€” output 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. this option can 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-exclusions are used, then 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. ๐ŸŒ

๐Ÿ’œ MORE HELP ๐Ÿ’œ

use dune COMMAND --help for help on a single command. because yes, every single one has its own page. slay. ๐Ÿ’…


๐Ÿ‘‘ EXIT STATUS ๐Ÿ‘‘

dune utop exits with:

  1. 0 โ€” on success. ๐ŸŽ‰
  2. 1 โ€” if an error happened. ๐Ÿ˜ญ
  3. 130 โ€” if it was interrupted by a signal. ๐Ÿ’€

๐ŸŒฟ ENVIRONMENT ๐ŸŒฟ

okay bestie so these are the env vars that literally change how utop runs under Dune. set them, unset them, whatever โ€” they're vibes you can hand to the process. ๐Ÿ’–

  • DUNE_BUILD_DIR โ€” the build directory you want. lowkey, if you don't say anything it's _build.
  • DUNE_CACHE โ€” turn the Dune cache on or off. it's one of disabled, enabled-except-user-rules or enabled. default is enabled-except-user-rules. periodt.
  • DUNE_CACHE_CHECK_PROBABILITY โ€” this one re-executes randomly chosen rules and compares the results with what's stored in the Dune cache, you know, just to check build reproducibility. heads up bestie: crank up the probability and your build gets slower. default probability is zero, so like, no rules get checked at all. ๐Ÿข
  • DUNE_CACHE_STORAGE_MODE โ€” the storage mode for the Dune cache. 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. use - to disable printing the diff entirely. โœจ
  • DUNE_DISABLE_PROMOTION โ€” disables all the promotion rules.
  • DUNE_INSTRUMENT_WITH โ€” enables instrumentation by BACKENDS. BACKENDS is a comma-separated list of library names, and each one of them must declare an instrumentation backend. no backend, no entry, iykyk.
  • DUNE_JOBS โ€” run no more than JOBS commands at the same time. JOBS has to be a positive integer, or auto to auto-detect the number of cores (which is the default, bestie).
  • DUNE_PROFILE โ€” the build profile. it's dev if unspecified, 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 doesn't change how targets given on the command line are interpreted โ€” it's only intended for scripts. ๐Ÿคซ
  • DUNE_SANDBOX โ€” the sandboxing mode to use by default. (peep --sandbox for the details, k?)
  • DUNE_STORE_ORIG_SOURCE_DIR โ€” store the original source location in the dune-package metadata.
  • DUNE_TARGET_EXEC โ€” a wrapper command 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 looking it up. no scavenger hunt needed. ๐Ÿ”

๐Ÿ› BUGS ๐Ÿ›

found something cursed? check the bug reports at https://github.com/ocaml/dune/issues โ€” the maintainers live there, fr fr. ๐Ÿ™ˆ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


okay that's the whole page, bestie, you're officially a dune-utop scholar now ๐Ÿ’…โœจ this was Dune 3.24.1, page DUNE-UTOP(1), and yes the date line at the bottom is just part of the manpage furniture โ€” slay, go build something iconic ๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from