Skip to content

feature(clean): accept source directories (#2288) - #15305

Merged
rgrinberg merged 1 commit into
mainfrom
fix-2288-clean-source-dirs
Nov 8, 2026
Merged

rgrinberg merged 1 commit into
mainfrom
fix-2288-clean-source-dirs

Conversation

@rgrinberg

Copy link
Copy Markdown
Member

Fixes #2288.

dune clean PATH previously only accepted paths inside the build directory
(e.g. _build/default/foo); passing a source directory failed with <path> is not inside the build directory. This makes dune clean accept source
directories (and the project root) too, mirroring how dune build PATH accepts
a source directory.

A source path is resolved against every build context and the corresponding
artifacts are removed (_build/<context>/<path>). For example:

$ dune clean foo   # removes _build/<context>/foo for every context
$ dune clean .     # cleans each build context

Paths already inside _build keep their previous behaviour, and dune clean
with no arguments still removes the whole build directory.

Implementation notes:

  • Arguments are partitioned: those already in _build are removed directly (no
    engine startup, as before); source paths are mapped across Context.DB.all.
  • Reading the contexts needs the engine, so when a source path is given the
    command now starts a server-less scheduler (go_without_rpc_server).

The clean.t test added in #15300 (which demonstrated the rejection) is
updated to assert the new behaviour.

🤖 Generated with Claude Code

@rgrinberg
rgrinberg force-pushed the fix-2288-clean-source-dirs branch from 999201e to 87ff91d Compare June 24, 2026 17:03
`dune clean PATH` now accepts source directories (and the project root), not
just paths inside the build directory. A source path is resolved against every
build context, mirroring how `dune build PATH` accepts a source directory, and
the corresponding build artifacts are removed. Paths already inside `_build`
keep their previous behaviour.

Reading the build contexts requires the engine, so when a source path is given
the command now starts a server-less scheduler to query `Context.DB.all`.

fixes #2288

Signed-off-by: Rudi Grinberg <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@rgrinberg
rgrinberg force-pushed the fix-2288-clean-source-dirs branch from 87ff91d to 2733122 Compare June 25, 2026 10:42
@rgrinberg
rgrinberg merged commit cc10216 into main Nov 8, 2026
27 of 29 checks passed
@rgrinberg
rgrinberg deleted the fix-2288-clean-source-dirs branch November 8, 2026 05:52
@Alizter Alizter added this to the 3.26.0 milestone Nov 8, 2026
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.

Cannot run dune clean on directories

2 participants