Skip to content

feat(pkg): allow lock-dir pkgs to dep on workspace pkgs (in&out) - #14822

Closed
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-mnvztyotquus
Closed

Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-mnvztyotquus

Conversation

@Alizter

@Alizter Alizter commented Jun 1, 2026 •

Copy link
Copy Markdown
Collaborator

A package in dune.lock can now name a workspace package in its (depends ...) field. The workspace package's install entries are materialised via the scoped install layout (#14373) and consed onto the lock-dir package's build env, so the build action sees the workspace package the same way it sees any other declared dep. Previously such an edge was rejected at validation time.

This is the first step of the "in-and-out" case from #8652.

Lock_dir.read_disk{,_exn} now take ~external_packages : Package_name.Set.t and validate_packages accepts an edge whose target is in the lockdir, is dune, or is in external_packages. Workspace-driven callers populate the set from local package names; dev-tool lockdirs and the solver's own output check pass empty, preserving strict validation. check_packages becomes a public helper so callers can stage parsing and validation separately (used by dev-tool loading in src/dune_rules/lock_dir.ml), and Make_load.load no longer validates — the removed load_exn was equivalent to load |> ok_exn.

Pkg.t and DB.Pkg_table.entry carry workspace_deps : Package.Name.Set.t next to the lock-dir-only depends. A new Resolved_dep variant classifies each declared edge as Lockdir | Workspace | Dune | System; anything not found in the lockdir, dune, or the system-provided set falls to Workspace. add_workspace_env builds an Install_layout for the lock-dir package's workspace_deps and conses its env onto the build action.

Related:

Follow-up

  • let the solver itself pick workspace packages (stacked PR)
  • mixed lock-dir + workspace deps on the same consumer

@Alizter
Alizter force-pushed the push-mnvztyotquus branch 4 times, most recently from 5772aed to d362bc7 Compare June 4, 2026 15:04
@Alizter Alizter added feature-request package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands and removed feature-request labels Jun 4, 2026
@Alizter
Alizter force-pushed the push-mnvztyotquus branch 2 times, most recently from 4c65d6e to 1493764 Compare June 8, 2026 10:58
@Alizter Alizter changed the title feat(pkg): allow lock dir pkgs to dep on workspace pkgs (in&out) feat(pkg): allow lock-dir pkgs to dep on workspace pkgs (in&out) Jun 8, 2026
@Alizter
Alizter force-pushed the push-mnvztyotquus branch 5 times, most recently from bc2ff9f to f5c1d93 Compare June 11, 2026 16:00
@Alizter
Alizter force-pushed the push-mnvztyotquus branch 3 times, most recently from e30e3ce to 58ff0dd Compare June 29, 2026 14:41
@Alizter
Alizter force-pushed the push-mnvztyotquus branch from 58ff0dd to dc5f606 Compare July 1, 2026 13:27
@Alizter
Alizter marked this pull request as ready for review July 1, 2026 13:27
@Alizter
Alizter force-pushed the push-mnvztyotquus branch 4 times, most recently from 79f021e to 45995c3 Compare July 8, 2026 20:40
@punchagan
punchagan self-requested a review July 9, 2026 12:14
@ElectreAAS
ElectreAAS self-requested a review July 9, 2026 16:42
A package in `dune.lock` can now name a workspace package in its
`(depends ...)` field. Workspace install entries are materialised via the
scoped install layout (ocaml#14373) and consed onto the lock-dir package build
env, so the build action sees the workspace package the same way it sees
any other declared dep. Previously such an edge was rejected at lock and
validation time. This is the first step of the "in-and-out" case from
ocaml#8652.

`Lock_dir.read_disk{,_exn}` now take `~external_packages :
Package_name.Set.t` and `validate_packages` accepts an edge whose target
is in the lockdir, is dune, or is in `external_packages`, while rejecting
ambiguous edges whose target appears both in the lockdir and in that
external set. Workspace-driven callers populate the set from local package
names; dev-tool lockdirs and the solver output check pass `empty`,
preserving strict validation. `check_packages` becomes a public helper so
callers can stage parsing and validation separately, and `Make_load.load`
no longer validates -- the removed `load_exn` was equivalent to
`load |> ok_exn`.

`Pkg.t` and `DB.Pkg_table.entry` carry `workspace_deps :
Package.Name.Set.t` next to the lock-dir-only `depends`. A new
`Resolved_dep` variant classifies each declared edge as `Lockdir |
Workspace | Dune | System | Unavailable_lockdir`; names that are not in
the lockdir, dune, or the system-provided set are workspace candidates,
and the lockdir validation path rejects candidates that are not real
workspace packages before package rules consume them. Build actions,
package variables, and binary resolution use the transitive workspace deps
of the lock-dir dependency closure.

Letting the solver itself pick workspace packages is a follow-up.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter force-pushed the push-mnvztyotquus branch from 45995c3 to 2676f65 Compare July 13, 2026 15:40
@Alizter
Alizter marked this pull request as draft July 13, 2026 19:00
@Alizter

Alizter commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

I've found some issues with some more complicated build graphs so marking as draft for now until I have resolved them. Reviews in the meantime are still welcome, but this is not finished.

@punchagan punchagan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This generally looks reasonable to me. I'd be to happy to discuss and work through the issues you mentioned appearing with more complicated build graphs.

Building rejects the lock dir because "myws" is a dependency of "mylock" but is
not itself a package in the lock dir. Lock-dir validation does not currently
recognise workspace packages as valid dependency targets.
The build accepts the workspace dependency and runs [mylock]'s build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't catch this in the previous PR merging these tests, but should this test be in lockdir-workspace-deps dir?

lockdir but unavailable for the current platform. Validation accepts
the edge because the name exists somewhere in the lockdir, but rule
generation resolves against the current platform subset and
misclassifies the unavailable lockdir package as a workspace

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment here needs updation!

@Alizter Alizter closed this Sep 9, 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