1DUNE-EXEC(1)                      Dune Manual                     DUNE-EXEC(1)
2
3
4

NAME

6       dune-exec - Execute a command in a similar environment as if
7       installation was performed.
8

SYNOPSIS

10       dune exec [OPTION]… PROG [ARGS]…
11

DESCRIPTION

13       dune exec -- COMMAND should behave in the same way as if you do:
14
15         $ dune install
16         $ COMMAND
17
18       In particular if you run dune exec ocaml, you will have access to the
19       libraries defined in the workspace using your usual directives
20       (#require for instance)
21
22       When a leading / is present in the command (absolute path), then the
23       path is interpreted as an absolute path
24
25       When a / is present at any other position (relative path), then the
26       path is interpreted as relative to the build context + current working
27       directory (or the value of --root when ran outside of the project root)
28

OPTIONS

30       --action-stderr-on-success=VAL
31           Same as --action-stdout-on-success but for the standard output for
32           error messages. A good default for large mono-repositories is
33           --action-stdout-on-success=swallow
34           --action-stderr-on-success=must-be-empty. This ensures that a
35           successful build has a "clean" empty output.
36
37       --action-stdout-on-success=VAL
38           Specify how to deal with the standard output of actions when they
39           succeed. Possible values are: print to just print it to Dune's
40           output, swallow to completely ignore it and must-be-empty to
41           enforce that the action printed nothing. With must-be-empty, Dune
42           will consider that the action failed if it printed something to its
43           standard output. The default is print.
44
45       --build-info
46           Show build information.
47
48       --context=CONTEXT (absent=default)
49           Run the command in this build context.
50
51       --error-reporting=VAL (absent=deterministic)
52           Controls when the build errors are reported. early - report errors
53           as soon as they are discovered. deterministic - report errors at
54           the end of the build in a deterministic order. twice - report each
55           error twice: once as soon as the error is discovered and then again
56           at the end of the build, in a deterministic order.
57
58       -f, --force
59           Force actions associated to aliases to be re-executed even if their
60           dependencies haven't changed.
61
62       --file-watcher=VAL (absent=automatic)
63           Mechanism to detect changes in the source. Automatic to make dune
64           run an external program to detect changes. Manual to notify dune
65           that files have changed manually."
66
67       --no-build
68           don't rebuild target before executing
69
70       --passive-watch-mode
71           Similar to [--watch], but only start a build when instructed
72           externally by an RPC.
73
74       --react-to-insignificant-changes
75           react to insignificant file system changes; this is only useful for
76           benchmarking dune
77
78       --sandbox=VAL (absent DUNE_SANDBOX env)
79           Sandboxing mode to use by default. Some actions require a certain
80           sandboxing mode, so they will ignore this setting. The allowed
81           values are: none, symlink, copy, hardlink.
82
83       -w, --watch
84           Instead of terminating build after completion, wait continuously
85           for file changes.
86
87       --wait-for-filesystem-clock
88           Dune digest file contents for better incrementally. These digests
89           are themselves cached. In some cases, Dune needs to drop some
90           digest cache entries in order for things to be reliable. This
91           option makes Dune wait for the file system clock to advance so that
92           it doesn't need to drop anything. You should probably not care
93           about this option; it is mostly useful for Dune developers to make
94           Dune tests of the digest cache more reproducible.
95

COMMON OPTIONS

97       These options are common to all commands.
98
99       --always-show-command-line
100           Always show the full command lines of programs executed by dune
101
102       --auto-promote
103           Automatically promote files. This is similar to running dune
104           promote after the build.
105
106       --build-dir=FILE (absent DUNE_BUILD_DIR env)
107           Specified build directory. _build if unspecified
108
109       --cache=VAL (absent DUNE_CACHE env)
110           Enable or disable Dune cache (either enabled or disabled). Default
111           is `disabled'.
112
113       --cache-check-probability=VAL (absent DUNE_CACHE_CHECK_PROBABILITY env)
114           Check build reproducibility by re-executing randomly chosen rules
115           and comparing their results with those stored in Dune cache. Note:
116           by increasing the probability of such checks you slow down the
117           build. The default probability is zero, i.e. no rules are checked.
118
119       --cache-storage-mode=VAL (absent DUNE_CACHE_STORAGE_MODE env)
120           Dune cache storage mode (one of auto, hardlink or copy). Default is
121           `auto'.
122
123       --config-file=FILE
124           Load this configuration file instead of the default one.
125
126       --debug-artifact-substitution
127           Print debugging info about artifact substitution
128
129       --debug-backtraces
130           Always print exception backtraces.
131
132       --debug-cache=VAL
133           Show debug messages on cache misses for the given cache layers.
134           Value is a comma-separated list of cache layer names. All available
135           cache layers: shared,workspace-local,fs.
136
137       --debug-dependency-path
138           In case of error, print the dependency path from the targets on the
139           command line to the rule that failed.
140
141       --debug-digests
142           Explain why Dune decides to re-digest some files
143
144       --debug-findlib
145           Debug the findlib sub-system.
146
147       --debug-load-dir
148           Print debugging info about directory loading
149
150       --debug-store-digest-preimage
151           Store digest preimage for all computed digests, so that it's
152           possible to reverse them later, for debugging. The digests are
153           stored in the shared cache (see --cache flag) as values, even if
154           cache is otherwise disabled. This should be used only for
155           debugging, since it's slow and it litters the shared cache.
156
157       --default-target=TARGET (absent=@@default)
158           Set the default target that when none is specified to dune build.
159
160       --diff-command=VAL (absent DUNE_DIFF_COMMAND env)
161           Shell command to use to diff files. Use - to disable printing the
162           diff.
163
164       --disable-promotion (absent DUNE_DISABLE_PROMOTION env)
165           Disable all promotion rules
166
167       --display=MODE
168           Control the display mode of Dune. See dune-config(5) for more
169           details.
170
171       --dump-memo-graph=FILE
172           Dumps the dependency graph to a file after the build is complete
173
174       --dump-memo-graph-format=FORMAT (absent=gexf)
175           File format to be used when dumping dependency graph
176
177       --dump-memo-graph-with-timing
178           With --dump-memo-graph, will re-run each cached node in the Memo
179           graph after building and include the runtime in the output. Since
180           all nodes contain a cached value, this will measure just the
181           runtime of each node
182
183       --help[=FMT] (default=auto)
184           Show this help in format FMT. The value FMT must be one of auto,
185           pager, groff or plain. With auto, the format is pager or plain
186           whenever the TERM env var is dumb or undefined.
187
188       --ignore-promoted-rules
189           Ignore rules with (mode promote), except ones with (only ...). The
190           variable %{ignoring_promoted_rules} in dune files reflects whether
191           this option was passed or not.
192
193       --instrument-with=BACKENDS (absent DUNE_INSTRUMENT_WITH env)
194           "Enable instrumentation by BACKENDS. BACKENDS is a comma-separated
195           list of library names, each one of which must declare an
196           instrumentation backend.
197
198       -j JOBS
199           Run no more than JOBS commands simultaneously.
200
201       --no-buffer
202           Do not buffer the output of commands executed by dune. By default
203           dune buffers the output of subcommands, in order to prevent
204           interleaving when multiple commands are executed in parallel.
205           However, this can be an issue when debugging long running tests.
206           With --no-buffer, commands have direct access to the terminal. Note
207           that as a result their output won't be captured in the log file.
208           You should use this option in conjunction with -j 1, to avoid
209           interleaving. Additionally you should use --verbose as well, to
210           make sure that commands are printed before they are being executed.
211
212       --no-config
213           Do not load the configuration file
214
215       --no-print-directory
216           Suppress "Entering directory" messages
217
218       --only-packages=PACKAGES
219           Ignore stanzas referring to a package that is not in PACKAGES.
220           PACKAGES is a comma-separated list of package names. Note that this
221           has the same effect as deleting the relevant stanzas from dune
222           files. It is mostly meant for releases. During development, it is
223           likely that what you want instead is to build a particular
224           <package>.install target.
225
226       -p PACKAGES, --for-release-of-packages=PACKAGES (required)
227           Shorthand for --release --only-packages PACKAGE. You must use this
228           option in your <package>.opam files, in order to build only what's
229           necessary when your project contains multiple packages as well as
230           getting reproducible builds.
231
232       --print-metrics
233           Print out various performance metrics after every build
234
235       --profile=VAL (absent DUNE_PROFILE env)
236           Select the build profile, for instance dev or release. The default
237           is dev.
238
239       --promote-install-files[=VAL] (default=true)
240           Promote the generated <package>.install files to the source tree
241
242       --release
243           Put dune into a reproducible release mode. This is in fact a
244           shorthand for --root . --ignore-promoted-rules --no-config
245           --profile release --always-show-command-line
246           --promote-install-files --default-target @install
247           --require-dune-project-file. You should use this option for release
248           builds. For instance, you must use this option in your
249           <package>.opam files. Except if you already use -p, as -p implies
250           this option.
251
252       --require-dune-project-file[=VAL] (default=true)
253           Fail if a dune-project file is missing.
254
255       --root=DIR
256           Use this directory as workspace root instead of guessing it. Note
257           that this option doesn't change the interpretation of targets given
258           on the command line. It is only intended for scripts.
259
260       --store-orig-source-dir (absent DUNE_STORE_ORIG_SOURCE_DIR env)
261           Store original source location in dune-package metadata
262
263       --terminal-persistence=MODE
264           Changes how the log of build results are displayed to the console
265           between rebuilds while in --watch mode. Supported modes: preserve,
266           clear-on-rebuild, clear-on-rebuild-and-flush-history.
267
268       --trace-file=FILE
269           Output trace data in catapult format (compatible with
270           chrome://tracing)
271
272       --verbose
273           Same as --display verbose
274
275       --version
276           Show version information.
277
278       --workspace=FILE (absent DUNE_WORKSPACE env)
279           Use this specific workspace file instead of looking it up.
280
281       -x VAL
282           Cross-compile using this toolchain.
283

MORE HELP

285       Use `dune COMMAND --help' for help on a single command.
286

EXIT STATUS

288       exec exits with the following status:
289
290       0   on success.
291
292       123 on indiscriminate errors reported on standard error.
293
294       124 on command line parsing errors.
295
296       125 on unexpected internal errors (bugs).
297

ENVIRONMENT

299       These environment variables affect the execution of exec:
300
301       DUNE_BUILD_DIR
302           Specified build directory. _build if unspecified
303
304       DUNE_CACHE
305           Enable or disable Dune cache (either enabled or disabled). Default
306           is `disabled'.
307
308       DUNE_CACHE_CHECK_PROBABILITY
309           Check build reproducibility by re-executing randomly chosen rules
310           and comparing their results with those stored in Dune cache. Note:
311           by increasing the probability of such checks you slow down the
312           build. The default probability is zero, i.e. no rules are checked.
313
314       DUNE_CACHE_STORAGE_MODE
315           Dune cache storage mode (one of auto, hardlink or copy). Default is
316           `auto'.
317
318       DUNE_DIFF_COMMAND
319           Shell command to use to diff files. Use - to disable printing the
320           diff.
321
322       DUNE_DISABLE_PROMOTION
323           Disable all promotion rules
324
325       DUNE_INSTRUMENT_WITH
326           "Enable instrumentation by BACKENDS. BACKENDS is a comma-separated
327           list of library names, each one of which must declare an
328           instrumentation backend.
329
330       DUNE_PROFILE
331           Build profile. dev if unspecified or release if -p is set.
332
333       DUNE_SANDBOX
334           Sandboxing mode to use by default. (see --sandbox)
335
336       DUNE_STORE_ORIG_SOURCE_DIR
337           Store original source location in dune-package metadata
338
339       DUNE_WORKSPACE
340           Use this specific workspace file instead of looking it up.
341

BUGS

343       Check bug reports at https://github.com/ocaml/dune/issues
344

SEE ALSO

346       dune(1)
347

EXAMPLES

349       1.  Run the executable named `my_exec':
350
351             dune exec my_exec
352
353       2.  Run the executable defined in `foo.ml' with the argument `arg':
354
355             dune exec -- ./foo.exe arg
356
357
358
359Dune n/a                                                          DUNE-EXEC(1)
Impressum