Skip to content

refactor(pkg): remove pkg digests - #16292

Merged
Alizter merged 2 commits into
ocaml:mainfrom
Alizter:remove-pkg-digest
Nov 24, 2026
Merged

Alizter merged 2 commits into
ocaml:mainfrom
Alizter:remove-pkg-digest

Conversation

@Alizter

@Alizter Alizter commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Key package targets by owner and name instead of lock digest. Remove dune pkg print-digest. Dev tools no longer share compiler or helper targets (dev-tool-merlin-stale-compiler.t).

No longer triggers a package rebuild:

The source-overlay regression was fixed on main in #17219.

Known regressions:

  • Change a transitive export from FOO=bar to FOO=baz: incremental installs bar/1.2.3; fresh installs baz/1.2.3 (exported-env.t).
  • Reorder two providers of foo: incremental keeps the old provider; fresh picks the other (installed-binary.t).

Part of #8652.

@Alizter Alizter added no changelog package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands labels Sep 1, 2026
@Alizter
Alizter marked this pull request as ready for review September 2, 2026 15:33
@Alizter
Alizter requested a balanced review from Copilot September 2, 2026 18:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Stable paths currently permit stale environment-dependent builds and case-insensitive package-root collisions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Removes digest-qualified package identities, using package names within isolated project and dev-tool universes instead.

Changes:

  • Reworks package databases, resolution, and build paths.
  • Removes Pkg_digest and dune pkg print-digest.
  • Updates package cram tests for the new layout.
File summaries
File Description
test/blackbox-tests/test-cases/pkg/withenv-path.t Updates package paths.
test/blackbox-tests/test-cases/pkg/variables.t Updates paths and diagnostics.
test/blackbox-tests/test-cases/pkg/unknown-package.t Updates unknown-package error.
test/blackbox-tests/test-cases/pkg/unavailable-package-source.t Updates source failure paths.
test/blackbox-tests/test-cases/pkg/toolchain-variables.t Updates toolchain path.
test/blackbox-tests/test-cases/pkg/substitute.t Updates dependency substitutions.
test/blackbox-tests/test-cases/pkg/source-with-directory-symlink.t Updates source paths.
test/blackbox-tests/test-cases/pkg/set-ocamlfind-destdir.t Updates install destination paths.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-dependant-dependencies.t Updates portable package roots.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-alternative-selection.t Updates selected package roots.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-older-common-version.t Removes digest lookup.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-custom-solver-env.t Uses name-based package path.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-custom-platforms.t Uses name-based package path.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-build-context-solver-env.t Uses name-based package path.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-basic.t Updates portable build paths.
test/blackbox-tests/test-cases/pkg/pkg-deps.t Updates package dependency paths.
test/blackbox-tests/test-cases/pkg/pkg-deps-lock.t Updates rule dependencies.
test/blackbox-tests/test-cases/pkg/patch.t Updates patch diagnostics.
test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t Updates opam variable paths.
test/blackbox-tests/test-cases/pkg/odoc/dev-tool-odoc-dune-tools-install.t Updates isolated odoc path.
test/blackbox-tests/test-cases/pkg/ocamllsp/dev-tool-ocamllsp-env-path-var.t Updates dev-tool environments.
test/blackbox-tests/test-cases/pkg/ocamllsp/dev-tool-ocamllsp-basic.t Updates ocamllsp path.
test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-which.t Updates ocamlformat lookup.
test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-install.t Updates ocamlformat install path.
test/blackbox-tests/test-cases/pkg/ocamlformat/dune Adds curl dependencies.
test/blackbox-tests/test-cases/pkg/ocaml-compiler.t Updates compiler package path.
test/blackbox-tests/test-cases/pkg/merlin/dev-tool-merlin-env.t Updates Merlin environment path.
test/blackbox-tests/test-cases/pkg/lock-directory-selection.t Updates package errors.
test/blackbox-tests/test-cases/pkg/installed-binary.t Updates install-cookie paths.
test/blackbox-tests/test-cases/pkg/install-symlinks/link-permission-error.t Updates symlink failure paths.
test/blackbox-tests/test-cases/pkg/install-symlinks/dir-symlink.t Updates directory-symlink paths.
test/blackbox-tests/test-cases/pkg/install-symlinks/broken-symlink.t Updates broken-symlink paths.
test/blackbox-tests/test-cases/pkg/install-missing-entry.t Updates missing-entry paths.
test/blackbox-tests/test-cases/pkg/install-action.t Updates install action output.
test/blackbox-tests/test-cases/pkg/ignored-dune-lock.t Updates inactive-lock error.
test/blackbox-tests/test-cases/pkg/helpers.sh Simplifies package path helper.
test/blackbox-tests/test-cases/pkg/findlib-meta-optional-directory.t Updates findlib diagnostic.
test/blackbox-tests/test-cases/pkg/fetch-symlinks/valid-links.t Updates fetched source paths.
test/blackbox-tests/test-cases/pkg/fetch-symlinks/link-to-parent.t Updates cycle diagnostics.
test/blackbox-tests/test-cases/pkg/fetch-symlinks/escaping-link.t Updates escaping-link diagnostics.
test/blackbox-tests/test-cases/pkg/fetch-symlinks/basic-cycle.t Updates cycle path.
test/blackbox-tests/test-cases/pkg/fetch-local-source.t Removes digest lookup.
test/blackbox-tests/test-cases/pkg/fetch-cache-symlink.t Updates cache expectations.
test/blackbox-tests/test-cases/pkg/extra-source-overlap-with-source.t Uses name-based source path.
test/blackbox-tests/test-cases/pkg/dune Updates cram dependencies.
test/blackbox-tests/test-cases/pkg/different-dune-in-path.t Uses direct package paths.
test/blackbox-tests/test-cases/pkg/dep-section-variables.t Updates section paths.
test/blackbox-tests/test-cases/pkg/default-exported-env.t Updates exported environment paths.
test/blackbox-tests/test-cases/pkg/build-with-executable-script-on-windows.t Updates Windows diagnostics.
test/blackbox-tests/test-cases/pkg/broken-symlink-in-dependency.t Updates dependency source paths.
test/blackbox-tests/test-cases/pkg/bin-narrowing/workspace-shadows-lockdir.t Updates narrowed PATH entries.
test/blackbox-tests/test-cases/pkg/bin-narrowing/transitive-deps.t Updates transitive PATH entries.
test/blackbox-tests/test-cases/pkg/bin-narrowing/resolve-program.t Updates resolved program paths.
test/blackbox-tests/test-cases/pkg/bin-narrowing/multi-package.t Updates multi-package paths.
test/blackbox-tests/test-cases/pkg/bin-narrowing/lockdir-deps.t Updates lock-directory paths.
test/blackbox-tests/test-cases/pkg/bin-narrowing/ambient-path-fallback.t Updates fallback PATH.
test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t Updates absolute package paths.
test/blackbox-tests/test-cases/describe/describe_location.t Updates described executable path.
src/dune_rules/pkg_rules.mli Removes digest API.
src/dune_rules/pkg_rules.ml Implements name-keyed package universes.
src/dune_rules/pkg_dev_tool.ml Adds per-package dev-tool root.
src/dune_rules/lock_dir.mli Removes optional dev-tool loader.
src/dune_rules/lock_dir.ml Removes optional dev-tool loading.
src/dune_rules/dune_rules.ml Removes exported digest API.
bin/pkg/print_digest.mli Deletes command interface.
bin/pkg/print_digest.ml Deletes digest command.
bin/pkg/group.ml Unregisters digest command.
Review details
  • Files reviewed: 64/67 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/dune_rules/pkg_rules.ml Resolved
Comment thread src/dune_rules/pkg_rules.ml Resolved
Comment thread src/dune_rules/pkg_rules.ml Resolved
@Alizter
Alizter marked this pull request as draft September 3, 2026 11:40
@Alizter
Alizter force-pushed the remove-pkg-digest branch 2 times, most recently from a3d1eb7 to 26aa8ac Compare September 7, 2026 15:21
Alizter added a commit that referenced this pull request Sep 7, 2026
Demonstrate that the compiler isn't currently shared between the main
build and a dev tool. This needs to be fixed before #16292.
@Alizter
Alizter force-pushed the remove-pkg-digest branch 3 times, most recently from 7d47cde to 74ee0aa Compare September 8, 2026 15:20
@Alizter
Alizter force-pushed the remove-pkg-digest branch 3 times, most recently from edbee21 to 816f089 Compare October 2, 2026 14:01
@Alizter
Alizter marked this pull request as ready for review October 2, 2026 14:01
@Alizter
Alizter marked this pull request as draft October 24, 2026 10:09
@Alizter
Alizter marked this pull request as ready for review November 17, 2026 15:51
@Alizter

Alizter commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

There were various missing environment dependencies in the package rules that weren't apparent before because the package digests invalidated the directory in which the rules were loaded and therefore avoided stale builds. Removing the digests has made these missing deps apparent. My plan is to reproduce and observe these in some test coverage and then fix the missing deps sperately before continuing with this PR>

Alizter added a commit that referenced this pull request Nov 21, 2026
Match cache misses against the exact package target rather than looking
for a digest in its path. This distinguishes the effect of reordering
extra sources from editing their contents.

Refs #16292.
Alizter added a commit that referenced this pull request Nov 22, 2026
…cks (#17163)

The project can lock a compiler whose `compiler-support` dependency
exists only as a project pin. Relocking OCaml-LSP finds the pinned
compiler but fails to resolve that dependency.

Refs #16292.
Alizter added a commit that referenced this pull request Nov 22, 2026
…ools (#17173)

Merlin and OCaml-LSP share a compiler target with each other, but not
with the project. Check the rule dependencies as well as the build
counts, and distinguish the helper shared by both tools from a package
used only by the project.

Refs #16292.
Alizter added a commit that referenced this pull request Nov 22, 2026
…verlay (#17169)

Install a package with an extra source that shadows a file from its
source tree, then remove the extra source and rebuild. Compare the
installed file with a fresh build so the test catches stale contents
without relying on the layout of the prepared source directory.

Refs #16292.
Alizter added a commit that referenced this pull request Nov 22, 2026
Have mock Merlin record a marker from the compiler during installation.
Changing only the project’s locked compiler recipe, without bumping its
version, distinguishes using the project compiler from re-solving for
the same version. With no explicit OCaml dependency, mock Merlin
currently reports `no-compiler` both times.

Refs #16292.
@Alizter
Alizter force-pushed the remove-pkg-digest branch 3 times, most recently from 65e7351 to 85815ab Compare November 22, 2026 16:04
@Alizter
Alizter marked this pull request as ready for review November 22, 2026 16:06
Alizter added a commit to Alizter/dune that referenced this pull request Nov 24, 2026
Package build rules without any build or install instrutions may still
use .files or extra_sources and these may mutate the sources. Therefore
we should always be sandboxing these particular rules.

Without sandboxing we may mutate _build in an untracked way and cause
consumers of source/ to miss invalidation. The current pkg digests mask
this rebuild by creating a new rule. In ocaml#16292 we remove the pkg digests
which exposed this particular bug.

The bug can be observed directly on main in the cram test, but basically
has no ill-effect at the moment.

Signed-off-by: Ali Caglayan <[email protected]>
Alizter added a commit that referenced this pull request Nov 24, 2026
Package build rules without any build or install instrutions may still
use .files or extra_sources and these may mutate the sources. Therefore
we should always be sandboxing these particular rules.

Without sandboxing we may mutate _build in an untracked way and cause
consumers of source/ to miss invalidation. The current pkg digests mask
this rebuild by creating a new rule. In
#16292 we remove the pkg digests
which exposed this particular bug.

The bug can be observed directly on main in the cram test, but basically
has no ill-effect at the moment.

Reproduced in #17213. Related to #16292.
@Alizter
Alizter force-pushed the remove-pkg-digest branch 2 times, most recently from cfb8a79 to 5a569d8 Compare November 24, 2026 14:34
Resolve each tool and its dependencies from its own lock directory and
generate their targets under that tool. Compiler packages follow the same
rule; tool locks keep the existing compiler version and pin policy.

Signed-off-by: Ali Caglayan <[email protected]>
This patch removes pkg digests. It exposes a few inconsistencies in the
pkg rules which are fixed as a result. It does however mean that
enviornment exports are not tracked, and the order of package deps can
affect binary lookup for conflicting binaries. Both of these issues are
not important enough to fix for the time being.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter merged commit ac0f200 into ocaml:main Nov 24, 2026
36 of 37 checks passed
@Alizter
Alizter deleted the remove-pkg-digest branch November 24, 2026 15:46
@Alizter Alizter added this to the 3.26.0 milestone Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants