DUNE(1)

πŸ’– DUNE(1) β€” the Dune Manual, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about the single most iconic build system in the OCaml cinematic universe. it's dune, it's giving composable build system for OCaml, and it's literally about to carry your whole project on its back. πŸŽ€


✨ NAME ✨

dune β€” a composable build system for OCaml πŸ’…


🌸 SYNOPSIS 🌸

dune build [--watch]
dune runtest [--watch]
dune exec NAME
dune utop [DIR]
dune install
dune init project NAME [PATH] [--libs=l1,l2 --ppx=p1,p2 --inline-tests]

πŸ¦‹ DESCRIPTION πŸ¦‹

so. Dune is a build system designed for OCaml projects only. it's not trying to be everything to everyone, it's just trying to be your everything. it focuses on giving you a consistent experience and it handles basically all the low-level details of OCaml compilation that you do NOT want to be thinking about at 2am. all you have to do is describe your project, and Dune does the rest. that's it. that's the deal. no cap. πŸ”₯

the scheme it implements is inspired by the one used inside Jane Street, adapted for the open source world. it has matured over a long time and is used daily by hundreds of developers, which means it is highly tested and productive. it ate, honestly. πŸ‘‘


πŸ’« COMMAND ALIASES πŸ’«

these are the little shortcut besties. same energy, shorter name.

  • printenv [OPTION]… [PATH] β€” an alias for env.
  • promote [--build-info] [--file] [OPTION]… [FILE]… β€” an alias for promotion apply.
  • test [OPTION]… [TEST]… β€” an alias for runtest.

πŸ‘‘ COMMANDS πŸ‘‘

the whole squad, in order, no one left behind:

  • build [OPTION]… [TARGET]… β€” build the given targets, or the default ones if none are given.
  • cache COMMAND … β€” manage Dune's shared cache of build artifacts.
  • clean [OPTION]… [PATH]… β€” clean the project.
  • describe [COMMAND] … β€” describe the workspace.
  • diagnostics [OPTION]… β€” fetch and return errors from the current build.
  • exec [OPTION]… PROG [ARGS]… β€” execute a command in a similar environment as if installation was performed.
  • external-lib-deps [OPTION]… [TARGET]… β€” moved to dune describe external-lib-deps. (it moved, we don't gatekeep, but also we're telling you where it went πŸ’€)
  • fmt [OPTION]… β€” format source code.
  • format-dune-file [OPTION]… [FILE] β€” format dune files.
  • help [--build-info] [--man-format=FMT] [OPTION]… [TOPIC] β€” additional Dune help.
  • init COMMAND … β€” command group for initializing Dune components.
  • install [OPTION]… [PACKAGE]… β€” install packages defined in the workspace.
  • installed-libraries [OPTION]… β€” print out libraries installed on the system.
  • internal COMMAND … β€” (yes it's just there, being mysterious, minding its business 🫢)
  • monitor [OPTION]… β€” connect to a Dune RPC server and monitor it.
  • ocaml COMMAND … β€” command group related to OCaml.
  • ocaml-merlin [OPTION]… β€” start a merlin configuration server.
  • package COMMAND … β€” experimental package management
  • pkg COMMAND … β€” experimental package management
  • promotion COMMAND … β€” control how changes are propagated back to source code.
  • rocq COMMAND … β€” command group related to Rocq.
  • rpc COMMAND … β€” Dune's RPC mechanism. Experimental.
  • rules [OPTION]… [TARGET]… β€” dump rules.
  • runtest [OPTION]… [TEST]… β€” run tests.
  • show COMMAND … β€” command group for showing information about the workspace
  • shutdown [OPTION]… β€” cancel and shutdown any builds in the current workspace.
  • subst [--build-info] [OPTION]… β€” substitute watermarks in source files.
  • tools COMMAND … β€” command group for wrapped tools.
  • top [OPTION]… [DIR] β€” print a list of toplevel directives for including directories and loading cma files.
  • trace COMMAND … β€” commands to view dune's event trace
  • uninstall [OPTION]… [PACKAGE]… β€” uninstall packages defined in the workspace.
  • upgrade [OPTION]… β€” upgrade projects across major Dune versions.
  • utop [OPTION]… [DIR] [ARGS]… β€” load library in utop.

🌈 COMMON OPTIONS 🌈

these ones are common to all commands. every single one. they're the universal besties. ✨

  • --help[=FMT] (default=auto) β€” show this help in format FMT. the value 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.
  • --version β€” show version information.

⭐ MORE HELP ⭐

use dune COMMAND --help for help on a single command. iykyk. πŸ™ˆ


πŸ’€ EXIT STATUS πŸ’€

dune exits with:

  • 0 β€” on success. we love a win. πŸŽ€
  • 1 β€” if an error happened. it's giving not our day. 😭
  • 130 β€” if it was interrupted by a signal.

🧚 ENVIRONMENT 🧚

these environment variables affect the execution of dune:

  • CLICOLOR β€” if different than 0, ANSI colors are supported and should be used when the program isn't piped. if equal to 0, don't output ANSI color escape codes
  • CLICOLOR_FORCE β€” if different than 0, ANSI colors should be enabled no matter what.
  • DUNE_CACHE_ROOT β€” if set, determines the location of all the different caches used by dune.

πŸ™ˆ BUGS πŸ™ˆ

check bug reports at https://github.com/ocaml/dune/issues β€” the devs are literally right there, go tell them, they're nice about it fr fr.


🌸 EXAMPLES 🌸

some little situations to manifest ✨

  1. Initialise a new project named foo:
dune init project foo
  1. Build all targets in the current source tree:
dune build
  1. Run the executable named bar:
dune exec bar
  1. Run all tests in the current source tree:
dune runtest
  1. Install all components defined in the project:
dune install
  1. Remove all build artefacts:
dune clean

πŸ’– that's the whole page bestie. every flag, every command, every env var, nothing skipped, nothing guessed. go build something iconic. periodt. πŸ’…

okay and lastly, the little signature at the bottom of the original: this is from Dune 3.24.1, and yes, this whole thing is the DUNE(1) page. take care of her, she's doing her best. 🫢✨

πŸ“¦ where this page comes from