Skip to content

Conversation

@nojb
Copy link
Collaborator

@nojb nojb commented May 26, 2025

This PR extends dune format-dune-file so that the Dune version of the current Dune project is used when formatting. If a file is passed as argument, then it is the Dune project that owns the file that is used. If formatting standard input, it is the Dune project containing the current directory that is used.

This fixes the isssue discussed in the thread starting at #10892 (comment).

This also opens the door to honouring the (formatting) settings of the current Dune project (cc @Khady, cf #3516).


val create_exn : default_is_cwd:bool -> specified_by_user:string option -> t
val create_exn
: ?from:string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just always passing this from argument? I don't think there's many callers and it would help us be assured that you didn't forget to set this somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Fixed, thanks.

bin/common.mli Outdated
Return the [Common.t] and the final configuration, which is the same as the one
returned in the [config] field of [Dune_rules.Workspace.workspace ()]) *)
val init : Builder.t -> t * Dune_config_file.Dune_config.t
val init : ?root:Workspace_root.t -> Builder.t -> t * Dune_config_file.Dune_config.t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for ~root here. Let's just pass it always

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d7a096. I ended up using a separate function instead of making the argument mandatory, so as to avoid too much code duplication.

@nojb
Copy link
Collaborator Author

nojb commented May 29, 2025

I added a warning when using dune format-dune-file inside Dune, as this may not give the expected results (root detection behaves differently in that case) and the (format-dune-file) action seems a better option in that case. dfc6027

@nojb nojb force-pushed the format-dune-file-with-project-version branch from 71304a1 to 209091f Compare May 29, 2025 19:21
let cwd = Sys.getcwd () in
let find from =
let cwd =
if Filename.is_relative from then Filename.concat (Sys.getcwd ()) from else from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Fpath.initial_cwd? The old code didn't use it before, but at least it only called getcwd once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

@nojb nojb force-pushed the format-dune-file-with-project-version branch from ceb3d10 to cc5a628 Compare May 30, 2025 06:39
@rgrinberg
Copy link
Member

Tests are failing in this one

nojb added 7 commits August 22, 2025 08:27
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
@nojb nojb force-pushed the format-dune-file-with-project-version branch from 9f9ceda to 0186adf Compare August 22, 2025 06:30
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
@nojb
Copy link
Collaborator Author

nojb commented Aug 22, 2025

Tests are failing in this one

Thanks, coming back to this PR after the holidays. The test error was due to INSIDE_DUNE being set in the tests so that any use of dune format-dune-file triggers a new warning suggesting to use (format-dune-file) instead. I just accepted the affected tests: ccb86c3

@mbarbin
Copy link
Contributor

mbarbin commented Aug 22, 2025

Thank you @nojb for this work. I wanted to note I'll be a happy a user of this as I have started some work for fixing mbarbin/dunolint#88 but it seems with this change there will be no further change required in dunolint.

However, I have some reservation about the warning, and that is due to the use case on itself, as discussed in #11605 I would like to have a supported way (and official!) to format dune files from OCaml. I would like to add a way to silence the warning, as a way to acknowledge that I am not doing something that will annoy the dune-devs! Thanks a lot.

@nojb
Copy link
Collaborator Author

nojb commented Aug 22, 2025

Thank you @nojb for this work. I wanted to note I'll be a happy a user of this as I have started some work for fixing mbarbin/dunolint#88 but it seems with this change there will be no further change required in dunolint.

Would you be able to test this PR and report back if indeed it works as expected? It would be nice to have some confirmation from an actual user.

However, I have some reservation about the warning, and that is due to the use case on itself, as discussed in #11605 I would like to have a supported way (and official!) to format dune files from OCaml. I would like to add a way to silence the warning, as a way to acknowledge that I am not doing something that will annoy the dune-devs! Thanks a lot.

If I understand correctly from #11605, the issue is only the potential triggering of this warning in tests of your code, right? If so, you can disable the warning simply by unsetting the variable INSIDE_DUNE. Would that work?

@mbarbin
Copy link
Contributor

mbarbin commented Aug 22, 2025

Thank you. I'll attempt to find a slot for this in the afternoon and try the integration in the tests as well.

Thanks for pointing me to the env var 👍 I'll check it out.

Besides the technical consideration of making it work today, I guess I am also trying to do some due diligence that my use case aligns with your longer term vision. Seeing a warning in my use to me is a hint that something may go wrong later on, hence my feedback. Does it make sense, or am I being too cautious? Thanks a lot!

@mbarbin
Copy link
Contributor

mbarbin commented Aug 22, 2025

@nojb I am getting started with the testing. It's been a while since I built dune from source, I have some questions - hopefully this won't be too noisy for this threads, otherwise let me know I'm happy to PM you instead with my progress.

I'm at ccb86c3 tip of this PR as of now.

make bootstrap + make dev gets me a binary which I can use in tests. I noticed a new _build/log file generated in tests whereas before there was none. The log contains:

 |  $ cat _build/log
+|  # dune format-dune-file
+|  # OCAMLPARAM: unset
+|  # Shared cache: enabled-except-user-rules
+|  # Shared cache location: /home/mathieu/.cache/dune/db
+|  # Workspace root:
+|  # $TESTCASE_ROOT

Is the fact that a log is created a behavior change of 3.20, or perhaps an artifact of building in dev mode? To be clear, I don't mind the log on its own, I just need to understand what I can reasonable commit to my cram tests, and what dune version I should require in my dev-package.

If I try to build your PR in release mode, I get this:

$ make release
Internal error, please report upstream including the contents of _build/log.
Description:
  ("Unexpected find result", { found = Not_found; lib.name = "pp" })
Raised at Stdune__Code_error.raise in file "stdune__Code_error.ml", line 11,
  characters 30-62
Called from Fiber__Scheduler.exec in file "fiber__Scheduler.ml", line 77,
  characters 8-11
-> required by ("<unnamed>", ())
-> required by ("<unnamed>", ())
-> required by ("<unnamed>", ())
-> required by ("load-dir", In_build_dir "default/test/blackbox-tests/utils")
-> required by ("toplevel", ())

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases. 
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.
Internal error, please report upstream including the contents of _build/log.
Description:
  ("Unexpected find result", { found = Not_found; lib.name = "csexp" })
Raised at Stdune__Code_error.raise in file "stdune__Code_error.ml", line 11,
  characters 30-62
Called from Fiber__Scheduler.exec in file "fiber__Scheduler.ml", line 77,
  characters 8-11
-> required by ("<unnamed>", ())
-> required by ("<unnamed>", ())
-> required by
   ("load-dir", In_build_dir "default/test/expect-tests/dune_rpc_e2e")
-> required by ("toplevel", ())
make: *** [Makefile:38: release] Error 1        

In a switch where I have pp=2.0.0 and csexp=1.5.2

$ cat _build/log
# ./_boot/dune.exe build @install -p dune --profile dune-bootstrap
# OCAMLPARAM: unset
# Shared cache: enabled-except-user-rules
# Shared cache location: /home/mathieu/.cache/dune/db
# Workspace root: /home/mathieu/dev/forks/dune/main
# Auto-detected concurrency: 8
# Dune context:
#  { name = "default"
#  ; kind = "default"
#  ; profile = User_defined "dune-bootstrap"
#  ; merlin = true
#  ; fdo_target_exe = None
#  ; build_dir = In_build_dir "default"
#  ; instrument_with = []
#  }
$ /home/mathieu/.opam/5.3.0/bin/ocamlc.opt -config > /tmp/dune_650f61_output

Thanks for your help!

@mbarbin
Copy link
Contributor

mbarbin commented Aug 22, 2025

@nojb apart from the warning and/or the _build/log question, I report that this PR fixes the formatting issue encountered with dune.3.20 when using dunolint as an Emacs reformatter.

I tested with dunolint.0.0.20250804 and a dune executable in the PATH built from your PR + 1 commit to bring back the formatting changes that were recently reverted:

✔️ From Emacs when saving a file enclosed in a dune-project with 3.20, the compact formatting is used. When saving a file enclosed in a dune-project, say with 3.17, the usual former format is used.

(I added the one commit on top to actually have a difference in formatting, otherwise it was hard to get a visual confirmation, but because this PR and the formatting are orthogonal, I consider this is a satisfactory test).

@nojb
Copy link
Collaborator Author

nojb commented Aug 22, 2025

I report that this PR fixes the formatting issue encountered with dune.3.20 when using dunolint as an Emacs reformatter.

Thanks for the confirmation! I haven't had time to look at your question yet, but I will get to it soon-ish :)

@nojb
Copy link
Collaborator Author

nojb commented Aug 23, 2025

Is the fact that a log is created a behavior change of 3.20, or perhaps an artifact of building in dev mode? To be clear, I don't mind the log on its own,

I believe it is a behaviour change of this PR in fact. In order to have dune format-dune-file detect the version of the Dune project containing the Dune file being formatted, more of the standard build infrastructure needs to be invoked, and this includes initializing the logging subsystem.

@nojb
Copy link
Collaborator Author

nojb commented Aug 23, 2025

If I try to build your PR in release mode, I get this:

make release is pretty finicky regarding dependencies. I normally use make dev for testing. In any case, I can make it work if I use make dev-deps before make release.

@nojb
Copy link
Collaborator Author

nojb commented Aug 23, 2025

Besides the technical consideration of making it work today, I guess I am also trying to do some due diligence that my use case aligns with your longer term vision. Seeing a warning in my use to me is a hint that something may go wrong later on, hence my feedback. Does it make sense, or am I being too cautious? Thanks a lot!

Actually, adding the warning is probably me being overly cautious that something else. Technically, Dune may not work very well if it is called recursively on the same workspace. However, special support could be added for this if/as needed (basically to have the "inner" Dune invocation emit an RPC request to the "outer one"). So perhaps the warning is premature and may not be needed in the end.

I'll remove the warning for now. Thanks for the review!

Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
@mbarbin
Copy link
Contributor

mbarbin commented Aug 23, 2025

Great, thank you!

Looking at your PR now, my take is that I am satisfied with it as far as the requirements I stated in #11605 so I will close that issue once this lands. Also, this fixes mbarbin/dunolint#88 which is nice (less immediate work to do in dunolint for me, yeah!). The timing of this PR is also on point, as we've seen the potential user-facing impact of formatting changes in dune files. In sum, I am thankful for your work!

more of the standard build infrastructure needs to be invoked, and this includes initializing the logging subsystem

I cannot quite explain why, but I feel a slight reluctance to this part. I was hoping the dune command would be comparable to, say ocamlformat FILE and not requiring to create files on the side, but I don't think this is a big deal. I'll leave that simply as a thought from an external user who doesn't know the implementation constraints of the code. Does that part happen when the --dune-version is supplied?

By the way, currently the help says:

$ dune format-dune-file --help
...
OPTIONS
       --dune-version=VERSION (absent=3.20)
           Which version of Dune language to use.

I'm not sure if the new version documentation takes the changes into account as I didn't see any new text in the diff.

@mbarbin
Copy link
Contributor

mbarbin commented Aug 23, 2025

By the way, I just saw @Khady express a desire to keep the formatting changes in 3.20. Because this breaks my dunolint editor workflow, my perspective is that, whatever you decide, I would like to request that you include this PR with the formatting changes whenever you release it (that being in 3.20.1 or 3.21). Thanks a lot!

@nojb
Copy link
Collaborator Author

nojb commented Aug 30, 2025

I think all issues raised so far have been addressed, so the PR could be merged in principle. @rgrinberg: what do you think?

@Alizter Alizter merged commit c611db2 into ocaml:main Aug 30, 2025
26 checks passed
@nojb
Copy link
Collaborator Author

nojb commented Aug 30, 2025

Thanks @Alizter!

@nojb nojb deleted the format-dune-file-with-project-version branch August 30, 2025 16:11
shonfeder added a commit to shonfeder/opam-repository that referenced this pull request Dec 15, 2025
CHANGES:

### Fixed

- Fix `include_subdirs qualified` incorrectly picking the furthest module
  instead of the closest when resolving module name ambiguities. (ocaml/dune#12587,
  @ElectreAAS and @Alizter)

- Fix: include the module alias in the transitive dependency closure with
  `(include_subdirs qualified)`. (ocaml/dune#12299, @anmonteiro)

- Improve error messages for invalid version formats containing non-ASCII
  characters. Previously, non-ASCII characters in version strings (e.g., `(lang
  dune è)` or `(using menhir π3.14)`) would fail with a generic "Invalid file"
  error. Now they display a clear message: "Invalid atom: contains non-ASCII
  character(s). Atoms must only contain ASCII characters." The fix is
  implemented at the lexer level, providing consistent error handling across all
  s-expression parsing. (ocaml/dune#12844, fixes ocaml/dune#12836, @benodiwal)

- Pass private modules with -H when this is available (ocaml/dune#12666, @rgrinberg)

- Allow multiple modules in `(modules_flags ...)`, in `coq.theory` (ocaml/dune#12733, @rlepigre)

- Improve error message for invalid version formats in both `(lang dune ...)` and
  `(using extension ...)` declarations. Changes "Atom of the form NNN.NNN expected"
  to "Invalid version. Version must be two numbers separated by a dot." (ocaml/dune#12833, @benodiwal)

- Fix crash when running `dune build @check` on a library with virtual modules.
  (ocaml/dune#12644, fixes ocaml/dune#12636, @Alizter)

- Provide a more informative error message when `(pkg enabled)` is put in
  `dune-project` instead of `dune-workspace`. (ocaml/dune#12802, fixes ocaml/dune#12801,
  @benodiwal)

- Improve error message when invalid version strings are used in `dune-project`
  files. Non-ASCII characters and malformed versions now show a helpful hint
  with an example of the correct format. (ocaml/dune#12794, fixes ocaml/dune#12751, @benodiwal)

- Stop hiding the `root_module` from the include path (ocaml/dune#12239, @rgrinberg)

- Allow `$ dune init` to work on absolute paths (ocaml/dune#12601, fixes ocaml/dune#7806,
  @rgrinberg)

- `(include_subdirs qualified)`: Add missing alias dependency to module group.
  (ocaml/dune#12530, @anmonteiro)

- Add Melange compilation to the `@all` alias in libraries (ocaml/dune#12628,
  @anmonteiro)

- Fix greedy version location in lang declarations. Previously, error locations for
  invalid lang versions would span multiple bytes for multi-byte UTF-8 characters,
  causing carets to appear misaligned and seemingly include the closing
  parenthesis. Now, error locations for ASCII strings show the full length (e.g.,
  "Ali" shows `^^^`), while non-ASCII strings show only the first byte (e.g., "è"
  shows `^`) to avoid multi-byte character display issues. (ocaml/dune#12869, fixes ocaml/dune#12806,
  @benodiwal)

- melange support: don't emit empty JavaScript modules for generated module
  aliases. (ocaml/dune#12464, @anmonteiro)

### Added

- (Experimental): Introduce the `library_parameter` stanza. It allows users to
  declare a parameter when using the OxCaml compiler.
  (ocaml/dune#11963, implements ocaml/dune#12084, @maiste)

- Added the ability to scroll horizontally in TUI. (ocaml/dune#12386, @Alizter)

- Feature: Include shell command that was executed when a cram test has
  occurred in the error message (ocaml/dune#12307, @rgrinberg)

-  support expanding variables in `(promote (into ..))` (ocaml/dune#12832, fixes ocaml/dune#12742,
   @anmonteiro)

- Add support for `%{cmt:...}` and `%{cmti:...}` variables to reference
  compiled annotation files (.cmt and .cmti) containing typed abstract syntax
  trees with location and type information. (ocaml/dune#12634, grants ocaml/dune#12633, @Alizter)

- Add `$ dune describe tests` to describe the tests in the workspace
  (@Gromototo, ocaml/dune#12545, fixes ocaml/dune#12030)

- Add `argv`, the process environment, and the dune version to the config event
  in the trace (ocaml/dune#12909, @rgrinberg)

- Allow `dune runtest` to properly run while a watch mode server is running.
  (ocaml/dune#12473, grants ocaml/dune#8114, @gridbugs and @ElectreAAS)

- Use copy-on-write (COW) when copying files on filesystems that support it
  (Btrfs, ZFS, XFS, etc), under Linux. (ocaml/dune#12074, fixes ocaml/dune#12071, @nojb)

- Add support for Tangled ATproto-based code repositories (ocaml/dune#12197, @avsm)

- Add support for instantiating OxCaml parameterised libraries.
  (ocaml/dune#12561, @art-w)

- Add a `(conflict_markers error|ignore)` option to the cram stanza. When
  `(conflict_markers error)` is set, the cram test will fail in the presence of
  conflict markers. Git, diff3 and jujutsu conflict markers are detected.
  (ocaml/dune#12538, ocaml/dune#12617, ocaml/dune#12655, fixes ocaml/dune#12512, @rgrinberg, @Alizter)

- Introduce a `%{ppx:lib1+..+libn}` stanza to make it possible to refer to ppx
  executables built by dune. This is useful for writing tests (ocaml/dune#12711,
  @rgrinberg)

- Introduce a `(dir ..)` field on packages defined in the `dune-project`. This
  field allows to associate a directory with a particular package. This makes
  dune automatically filter out all stanzas in this directory and its
  descendants with `--only-packages`. All users are recommended to switch to
  using this field. (ocaml/dune#12614, fixes ocaml/dune#3255, @rgrinberg)

- Add support for `DUNE_ROOT` environment variable, similar to the existing
  `--root` CLI parameter. (fixes ocaml/dune#12399 @sir4ur0n)

- Introduce an `unused-libs` alias to detect unused libraries.
  (ocaml/dune#12623, fixes ocaml/dune#650, @rgrinberg)

- Add `--files` flag to `dune describe opam-files` to print only the names of
  the opam files line by line. (ocaml/dune#9793, @reynir and @Alizter)

- `dune exec` now accepts absolute paths inside the workspace.
  (ocaml/dune#12094, @Alizter)

- Add `coqdoc_header` and `coqdoc_footer` fields to the `coq` field of the
  `env` stanza, and to the `coq.theory` stanza, allowing to configure a
  custom header or footer respectively in the HTML output of `coqdoc`.
  (ocaml/dune#11131, @rlepigre)

- Allow `dune fmt` to properly run while a watch mode server is running.
  Note that the `--preview` flag is not supported in this mode.
  (ocaml/dune#12064, @ElectreAAS)

- Support for generating `_CoqProject` files for `coq.theory` stanzas.
  (ocaml/dune#11752, @rlepigre)

- Added `(files)` stanza, similar to `(dirs)` to control which files are visible
  to Dune on a per-directory basis. (ocaml/dune#12879, @nojb)
- Add support for %{ocaml-config:ox} (ocaml/dune#12236, @jonludlam)

- Introduce `dune promotion show` command to display the contents of corrected
  files that are ready for promotion. This allows users to preview changes
  before running `dune promote`. The command accepts file arguments to show
  specific files, or displays all promotable files when called without
  arguments. (ocaml/dune#12669, fixes ocaml/dune#3883, @MixiMaxiMouse)
- New `(lang rocq)` build mode for Rocq 9.0 and later. This new mode
  is very similar to the existing `(lang coq)`, except that it doesn't
  need the `coq*` compatibility wrappers. As of today `(lang rocq)`
  doesn't support yet composed builds with Rocq itself, this will be
  added later.  `(lang coq)` is deprecated, development is frozen, and
  will be removed at some point in the future. (ocaml/dune#12035, @ejgallego,
  @Lysxia, fixes ocaml/dune#11572)

### Changed

- Don't run `ocamldep` to compute false dependencies on the `root_module`
  (ocaml/dune#12227, @rgrinberg)

- `dune format-dune-file` now uses the syntax version of the Dune project that
  contains the file being formatted (if any) instead of using the latest version
  available, which remains the default if there is no Dune project in scope.
  (ocaml/dune#11865, @nojb)

- Persistent DB and process events have been slightly modified. Persistent
  DB events have more concise names and job events always include full
  information. (ocaml/dune#12867, @rgrinberg)

- Removed the `--trace-extended` flag. Its functionality is always enabled when
  tracing is active (ocaml/dune#12908, @rgrinberg)

- The `test/dune` file generated by `dune init proj` now depends on the project library. (ocaml/dune#12791, @shonfeder)

- Starting with version 3.21 of the Dune language, Dune no longer changes the
  default set of compiler warnings. For users that would like to keep the old
  behaviour, the variable `%{dune-warnings}` can be used in an `(env)` stanza in
  a top-level Dune file: `(env (dev (flags :standard %{dune-warnings})))`.
  (ocaml/dune#12766, @nojb)
- Fix: stop generating `cmt` files for cinaps binaries (ocaml/dune#12530, @rgrinberg)
shonfeder added a commit to shonfeder/opam-repository that referenced this pull request Jan 5, 2026
CHANGES:

### Fixed

- Fix `include_subdirs qualified` incorrectly picking the furthest module
  instead of the closest when resolving module name ambiguities. (ocaml/dune#12587,
  @ElectreAAS and @Alizter)

- Fix: include the module alias in the transitive dependency closure with
  `(include_subdirs qualified)`. (ocaml/dune#12299, @anmonteiro)

- Improve error messages for invalid version formats containing non-ASCII
  characters. Previously, non-ASCII characters in version strings (e.g., `(lang
  dune è)` or `(using menhir π3.14)`) would fail with a generic "Invalid file"
  error. Now they display a clear message: "Invalid atom: contains non-ASCII
  character(s). Atoms must only contain ASCII characters." The fix is
  implemented at the lexer level, providing consistent error handling across all
  s-expression parsing. (ocaml/dune#12844, fixes ocaml/dune#12836, @benodiwal)

- Pass private modules with -H when this is available (ocaml/dune#12666, @rgrinberg)

- Allow multiple modules in `(modules_flags ...)`, in `coq.theory` (ocaml/dune#12733, @rlepigre)

- Improve error message for invalid version formats in both `(lang dune ...)` and
  `(using extension ...)` declarations. Changes "Atom of the form NNN.NNN expected"
  to "Invalid version. Version must be two numbers separated by a dot." (ocaml/dune#12833, @benodiwal)

- Fix crash when running `dune build @check` on a library with virtual modules.
  (ocaml/dune#12644, fixes ocaml/dune#12636, @Alizter)

- Provide a more informative error message when `(pkg enabled)` is put in
  `dune-project` instead of `dune-workspace`. (ocaml/dune#12802, fixes ocaml/dune#12801,
  @benodiwal)

- Improve error message when invalid version strings are used in `dune-project`
  files. Non-ASCII characters and malformed versions now show a helpful hint
  with an example of the correct format. (ocaml/dune#12794, fixes ocaml/dune#12751, @benodiwal)

- Stop hiding the `root_module` from the include path (ocaml/dune#12239, @rgrinberg)

- Allow `$ dune init` to work on absolute paths (ocaml/dune#12601, fixes ocaml/dune#7806,
  @rgrinberg)

- `(include_subdirs qualified)`: Add missing alias dependency to module group.
  (ocaml/dune#12530, @anmonteiro)

- Add Melange compilation to the `@all` alias in libraries (ocaml/dune#12628,
  @anmonteiro)

- Fix greedy version location in lang declarations. Previously, error locations for
  invalid lang versions would span multiple bytes for multi-byte UTF-8 characters,
  causing carets to appear misaligned and seemingly include the closing
  parenthesis. Now, error locations for ASCII strings show the full length (e.g.,
  "Ali" shows `^^^`), while non-ASCII strings show only the first byte (e.g., "è"
  shows `^`) to avoid multi-byte character display issues. (ocaml/dune#12869, fixes ocaml/dune#12806,
  @benodiwal)

- melange support: don't emit empty JavaScript modules for generated module
  aliases. (ocaml/dune#12464, @anmonteiro)

### Added

- (Experimental): Introduce the `library_parameter` stanza. It allows users to
  declare a parameter when using the OxCaml compiler.
  (ocaml/dune#11963, implements ocaml/dune#12084, @maiste)

- Added the ability to scroll horizontally in TUI. (ocaml/dune#12386, @Alizter)

- Feature: Include shell command that was executed when a cram test has
  occurred in the error message (ocaml/dune#12307, @rgrinberg)

-  support expanding variables in `(promote (into ..))` (ocaml/dune#12832, fixes ocaml/dune#12742,
   @anmonteiro)

- Add support for `%{cmt:...}` and `%{cmti:...}` variables to reference
  compiled annotation files (.cmt and .cmti) containing typed abstract syntax
  trees with location and type information. (ocaml/dune#12634, grants ocaml/dune#12633, @Alizter)

- Add `$ dune describe tests` to describe the tests in the workspace
  (@Gromototo, ocaml/dune#12545, fixes ocaml/dune#12030)

- Add `argv`, the process environment, and the dune version to the config event
  in the trace (ocaml/dune#12909, @rgrinberg)

- Allow `dune runtest` to properly run while a watch mode server is running.
  (ocaml/dune#12473, grants ocaml/dune#8114, @gridbugs and @ElectreAAS)

- Use copy-on-write (COW) when copying files on filesystems that support it
  (Btrfs, ZFS, XFS, etc), under Linux. (ocaml/dune#12074, fixes ocaml/dune#12071, @nojb)

- Add support for Tangled ATproto-based code repositories (ocaml/dune#12197, @avsm)

- Add support for instantiating OxCaml parameterised libraries.
  (ocaml/dune#12561, @art-w)

- Add a `(conflict_markers error|ignore)` option to the cram stanza. When
  `(conflict_markers error)` is set, the cram test will fail in the presence of
  conflict markers. Git, diff3 and jujutsu conflict markers are detected.
  (ocaml/dune#12538, ocaml/dune#12617, ocaml/dune#12655, fixes ocaml/dune#12512, @rgrinberg, @Alizter)

- Introduce a `%{ppx:lib1+..+libn}` stanza to make it possible to refer to ppx
  executables built by dune. This is useful for writing tests (ocaml/dune#12711,
  @rgrinberg)

- Introduce a `(dir ..)` field on packages defined in the `dune-project`. This
  field allows to associate a directory with a particular package. This makes
  dune automatically filter out all stanzas in this directory and its
  descendants with `--only-packages`. All users are recommended to switch to
  using this field. (ocaml/dune#12614, fixes ocaml/dune#3255, @rgrinberg)

- Add support for `DUNE_ROOT` environment variable, similar to the existing
  `--root` CLI parameter. (fixes ocaml/dune#12399 @sir4ur0n)

- Introduce an `unused-libs` alias to detect unused libraries.
  (ocaml/dune#12623, fixes ocaml/dune#650, @rgrinberg)

- Add `--files` flag to `dune describe opam-files` to print only the names of
  the opam files line by line. (ocaml/dune#9793, @reynir and @Alizter)

- `dune exec` now accepts absolute paths inside the workspace.
  (ocaml/dune#12094, @Alizter)

- Add `coqdoc_header` and `coqdoc_footer` fields to the `coq` field of the
  `env` stanza, and to the `coq.theory` stanza, allowing to configure a
  custom header or footer respectively in the HTML output of `coqdoc`.
  (ocaml/dune#11131, @rlepigre)

- Allow `dune fmt` to properly run while a watch mode server is running.
  Note that the `--preview` flag is not supported in this mode.
  (ocaml/dune#12064, @ElectreAAS)

- Support for generating `_CoqProject` files for `coq.theory` stanzas.
  (ocaml/dune#11752, @rlepigre)

- Added `(files)` stanza, similar to `(dirs)` to control which files are visible
  to Dune on a per-directory basis. (ocaml/dune#12879, @nojb)
- Add support for %{ocaml-config:ox} (ocaml/dune#12236, @jonludlam)

- Introduce `dune promotion show` command to display the contents of corrected
  files that are ready for promotion. This allows users to preview changes
  before running `dune promote`. The command accepts file arguments to show
  specific files, or displays all promotable files when called without
  arguments. (ocaml/dune#12669, fixes ocaml/dune#3883, @MixiMaxiMouse)
- New `(lang rocq)` build mode for Rocq 9.0 and later. This new mode
  is very similar to the existing `(lang coq)`, except that it doesn't
  need the `coq*` compatibility wrappers. As of today `(lang rocq)`
  doesn't support yet composed builds with Rocq itself, this will be
  added later.  `(lang coq)` is deprecated, development is frozen, and
  will be removed at some point in the future. (ocaml/dune#12035, @ejgallego,
  @Lysxia, fixes ocaml/dune#11572)

### Changed

- Don't run `ocamldep` to compute false dependencies on the `root_module`
  (ocaml/dune#12227, @rgrinberg)

- `dune format-dune-file` now uses the syntax version of the Dune project that
  contains the file being formatted (if any) instead of using the latest version
  available, which remains the default if there is no Dune project in scope.
  (ocaml/dune#11865, @nojb)

- Persistent DB and process events have been slightly modified. Persistent
  DB events have more concise names and job events always include full
  information. (ocaml/dune#12867, @rgrinberg)

- Removed the `--trace-extended` flag. Its functionality is always enabled when
  tracing is active (ocaml/dune#12908, @rgrinberg)

- The `test/dune` file generated by `dune init proj` now depends on the project library. (ocaml/dune#12791, @shonfeder)

- Starting with version 3.21 of the Dune language, Dune no longer changes the
  default set of compiler warnings. For users that would like to keep the old
  behaviour, the variable `%{dune-warnings}` can be used in an `(env)` stanza in
  a top-level Dune file: `(env (dev (flags :standard %{dune-warnings})))`.
  (ocaml/dune#12766, @nojb)
- Fix: stop generating `cmt` files for cinaps binaries (ocaml/dune#12530, @rgrinberg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants