dune-init man page

dune-init ā€” Initialize dune components




dune init {library,executable,test,project} NAME [PATH] initialize a new dune component of the specified kind, named NAME, with fields determined by the supplied options.

Any prefix of the component kinds can be supplied, e.g., dune init proj myproject.

If the optional PATH is provided, the component will be created there. Otherwise, it is created in the current working directory.

The command can be used to add stanzas to existing dune files as well as for creating new dune files and basic component templates.



Show build information.

-f, --force

Force actions associated to aliases to be re-executed even if their dependencies haven't changed.

--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.


Whether to use inline tests. Only applicable for library and project components.


The kind of project to initialize. Valid options are e[xecutable] or l[ibrary]. Defaults to executable. Only applicable for project components.


Libraries on which the component depends


Which package manager to use. Valid options are o[pam] or e[sy]. Defaults to opam. Only applicable for project components.


ppx preprocessors used by the component

--public[=PUBLIC_NAME] (default=)

If called with an argument, make the component public under the given PUBLIC_NAME. If supplied without an argument, use NAME.


Show version information.

-w, --watch

Instead of terminating build after completion, wait continuously for file changes.

Common Options


Always show the full command lines of programs executed by dune


Automatically promote files. This is similar to running dune promote after the build.

--build-dir=FILE (absent DUNE_BUILD_DIR env)

Specified build directory. _build if unspecified


Load this configuration file instead of the default one.


Always print exception backtraces.


In case of error, print the dependency path from the targets on the command line to the rule that failed.


Debug the findlib sub-system.

--default-target=TARGET (absent=@@default)

Set the default target that when none is specified to dune build.


Same as --profile dev


Shell command to use to diff files. Use - to disable printing the diff.


Control the display mode of Dune. See dune-config(5) for more details.


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.


Run no more than JOBS commands simultaneously.


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 --verbose as well, to make sure that commands are printed before they are being executed.


Do not load the configuration file


Suppress "Entering directory" messages


Ignore stanzas referring to a package that is not in PACKAGES. PACKAGES is a comma-separated list of package names. Note that this has the same effect as deleting the relevant stanzas from jbuild files. It is mostly meant for releases. During development, it is likely that what you want instead is to build a particular <package>.install target.

-p PACKAGES, --for-release-of-packages=PACKAGES

Shorthand for --root . --only-packages PACKAGE --ignore-promoted-rules --no-config --profile release. You must use this option in your <package>.opam files, in order to build only what's necessary when your project contains multiple packages as well as getting reproducible builds.

--profile=VAL (absent DUNE_PROFILE env)

Select the build profile, for instance dev or release. The default is dev.


Use this directory as 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 (absent DUNE_STORE_ORIG_SOURCE_DIR env)

Store original source location in dune-package metadata


Output trace data in catapult format (compatible with chrome://tracing)


Same as --display verbose

--workspace=FILE (absent DUNE_WORKSPACE env)

Use this specific workspace file instead of looking it up.

-x VAL

Cross-compile using this toolchain.


These environment variables affect the execution of init:


Specified build directory. _build if unspecified


Build profile. dev if unspecified or release if -p is set.


Store original source location in dune-package metadata


Use this specific workspace file instead of looking it up.


Define an executable component named 'myexe' in a dune file in the
current directory:

          dune init exe myexe

Define a library component named 'mylib' in a dune file in the ./src
directory depending on the core and cmdliner libraries, the ppx_let
and ppx_inline_test preprocessors, and declared as using inline tests:

          dune init lib mylib src --libs core,cmdliner --ppx ppx_let,ppx_inline_test --inline-tests

Define a library component named mytest in a dune file in the ./test
directory that depends on mylib:

        dune init test myexe test --libs mylib


Dune n/a Dune Manual