Skip to content

Fix dune formatting to make sure the right version is picked #168

@mbarbin

Description

@mbarbin

As of the current tip of dunolint, we've made in #167 some fixes to the build and tests so we can support dune 3.21 to dev on the project, however the migration of the app itself is not completely done at this point.

So what's missing?

This is a about the dune format-dune-file command which changed and now will detect the lang version to use based on the enclosing dune-project file containing the file to be formatted. And , the actual rendering format in 3.21 has changed in very visible fashion so this matters.

The issue with dunolint is that it calls this command on raw memory string contents without carrying the information of where the string comes from on disk, which will inevitably result in mismatches. Dune uses the command cwd when formatting the contents read from stdin, and dunolint always calls this command with the rundir equals to the overall project ROOT, so in practice if you dunolint a large project with subrepo with different version of dune lang specified in dune-project in subdirs, that's when things would go out of sync.

I think the linting on save with editor is correct (though not tested with the recent tip) because the command shall be running in the directory containing the buffer to lint. To be confirmed.

To resolve this we'd need a few refactor to dunolint to make sure to carry the information needed to format files using the right format. Note that, if no changes are to be applied by dunolint rules, the files won't get formatted (dunolint keep the original) - thus the actual impact should be minimal for now (I would think?) but this shall be resolved before too many projects starting using (lang dune 3.21) otherwise this could become a friction point.

Metadata

Metadata

Assignees

Labels

adoption hurdleSomething prevents enabling the toolbugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions