Dune 3.7.0

The dune team is pleased to announce the release of Dune 3.7.0.

As in the previous announce, here is a changelog split in several parts: changes to the dune executable itself (new commands or options, etc) and changes to the dune language. Most of the changes to the latter are only enabled when you opt-in to the new version by specifying (lang dune 3.7) in the corresponding dune-project file. In other words, it should always be safe to upgrade the dune package.

🌟 Spotlight Features

  1. Watch mode for executables

Dune 3.7 now supports watch mode for executables! 🎉

It works just as you'd expect, if you define an executable, you can run it with

dune exec -w my-executable

It will interrupt the process when a file change and re-start the application.

For a practical example of the workflows enabled by watch-mode, check this demo of a live reload for web development:

  1. Native Windows Polling

Starting from Dune 3.7, Dune watch mode is now available on Windows!

@yams-yams and @nojb from Lexifi have been working on integrating Windows native polling API with Dune to supplement the support for fswatch, which is unavailable on Windows.

Windows users can now run dune build -w out of the box!

  1. Qualified Subdirs

It's quite common to organise your code into subdirectories to separate components. Until now, you could do this by including (include_subdirs unqualified) in your dune files, but this wasn't completely satisfying since all of your modules were available in the top-level. If you wanted to expose modules in subdirectories under another module, you had to create a separate library, which was.. quite the overhead.

Dune 3.7 brings support for the highly-anticipated qualified sub-directories. You can now write (include_subdirs qualified) in your dune file, and modules in your subdirectories will be exposed under a module with the name of the directory.

See full changelog

dune executable

Added

  • Allow running $ dune exec in watch mode (with the -w flag). In watch mode, $ dune exec the executed binary whenever it is recompiled. (#6966, @gridbugs)

  • Add a dune cache size command for displaying the size of the cache (#6638, @Alizter)

  • Allow $ dune ocaml dump-dot-merlin to run in watch mode. Also this command shouldn't print "Entering Directory" mesages. (#6497, @rgrinberg)

  • Add native support for polling mode on Windows (#7010, @yams-yams, @nojb, review by @Rucikir and @jbeckford)

  • Auto-detect dune-workspace files as dune files in Emacs (#7061, @ilankri)

  • Allow $ dune utop to load libraries defined in data only directories defined using (subdir ..) (#6631, @rgrinberg)

Changed

  • Make dune describe workspace return consistent dependencies for executables and for libraries. By default, compile-time dependencies towards PPX-rewriters are from now not taken into account (but runtime dependencies always are). Compile-time dependencies towards PPX-rewriters can be taken into account by providing the --with-pps flag. (#6727, fixes #6486, @esope)

  • Use colored output with MDX when Dune colors are enabled. (#6462, @MisterDA)

  • Use colored output with GCC and Clang when compiling C stubs. The flag -fdiagnostics-color=always is added to the :standard set of flags. (#4083, @MisterDA)

  • Move $ dune ocaml-merlin -dump-config=$dir to $ dune ocaml merlin dump-config $dir. (#6547, @rgrinberg)

Fixed

  • Fix parsing of OCaml errors that contain code excerpts with ... in them. (#7008, @rgrinberg)

  • Fix --trace-file output. Dune now emits a single complete event for every executed process. Unterminated async events are no longer written. (#6892, @rgrinberg)

  • Print missing newline after $ dune exec. (#6821, fixes #6700, @rgrinberg, @Alizter)

  • Fix binary corruption when installing or promoting in parallel (#6669, fixes #6668, @edwintorok)

  • Report an error if dune init ... would create a "dune" file in a location which already contains a "dune" directory (#6705, @gridbugs)

  • Fix the parsing of alerts. They will now show up in diagnostics correctly. (#6678, @rginberg)

  • Print "Leaving Directory" whenever "Entering Directory" is printed. (#6419, fixes #138, @cpitclaudel, @rgrinberg)

  • Remove "Entering Directory" messages for $ dune install. (#6513, @rgrinberg)

  • dune clean should no longer fail under Windows due to the inability to remove the .lock file. Also, bring the implementation of the global lock under Windows closer to that of Unix. (#6523, @nojb)

  • Fix missing dependencies when detecting the kind of C compiler we're using (#6610, fixes #6415, @emillon)

  • Remove spurious build dir created when running dune init proj ... (#6707, fixes #5429, @gridbugs)

  • Validate the command line arguments for $ dune ocaml top-module. This command requires one positional argument (#6796, fixes #6793, @rgrinberg)

  • Fix dependency cycle when installing files to the bin section with glob_files (#6764, fixes #6708, @gridbugs)

  • Handle "Too many links" errors when using Dune cache on Windows (#6993, @nojb)

  • Pre-emptively clear screen in watch mode (#6987, fixes #6884, @rgrinberg)

  • Allow --sandbox to affect ocamldep invocations. Previously, they were wrongly marked as incompatible (#6749, @rgrinberg)

dune language

Added

  • Allow (include_subdirs qualified) for OCaml projects. (#6594, fixes #1084, @rgrinberg)

  • Format dune files when they are named dune-file. This occurs when we enable the alternative file names project option. (#6566, @rgrinberg)

  • Add map_workspace_root dune-project stanza to allow disabling of mapping of workspace root to /workspace_root. (#6988, fixes #6929, @richardlford)

  • Allow the cinaps stanza to set a custom alias. By default, if the alias is not set then the cinaps actions will be attached to both @cinaps and @runtest (#6991, @rgrinberg)

  • Add (using ctypes 0.3). When used, paths in (ctypes) are interpreted relative to where the stanza is defined. (#6883, fixes #5325, @emillon)

Changed

  • Stop passing -q flag in dune coq top, which allows for .coqrc to be loaded. (#6848, fixes #6847, @Alizter)

  • Coq native mode is now automatically detected by Dune starting with Coq lang 0.7. (mode native) has been deprecated in favour of detection from the configuration of Coq. (#6409, @Alizter)

  • Accurately determine merlin configuration for all sources selected with copy# and copy_files#. The old heuristic of looking for a module in parent directories is removed (#6594, @rgrinberg)

Fixed

  • Fix parsing of the <= operator in blang expressions of dune files. Previously, the operator would be interpreted as <. (#6928, @tatchi)

  • Fix preprocessing with staged_pps (#6748, fixes #6644, @rgrinberg)

  • Fix the parsing of decimal and hexadecimal escape literals in dune, dune-package, and other dune s-expression based files (#6710, @shym)

  • Fix cross compilation configuration when a context with targets is itself a host of another context (#6958, fixes #6843, @rgrinberg)

  • Allow compilation rules to be impacted by (env ..) stanzas that modify the environment or set binaries. (#6527, @rgrinberg)

  • Fix handling of support files generated by odoc. (#6913, @jonludlam)

  • Fix the compilation of modules generated at link time when implicit_transitive_deps is enabled (#6642, @rgrinberg)

  • Fix inline tests with js_of_ocaml and whole program compilation mode enabled (#6645, @hhugo)

  • Fix js_of_ocaml separate compilation rules when --enable=effects ,--enable=use-js-string or --toplevel is used. (#6714, #6828, #6920, @hhugo)

  • Fix js_of_ocaml separate compilation in presence of linkall (#6832, #6916, @hhugo)

  • coqdep is now called once per theory, instead of one time per Coq file. This should significantly speed up some builds, as coqdep startup time is often heavy (#7048, @Alizter, @ejgallego)