Skip to content

Comments

Collapse resolver incompatiblities for workspace members#6090

Closed
zanieb wants to merge 3 commits intomainfrom
zb/resolver-workspace-member
Closed

Collapse resolver incompatiblities for workspace members#6090
zanieb wants to merge 3 commits intomainfrom
zb/resolver-workspace-member

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Aug 14, 2024

Part of #6066

Transforms the derivation tree to exclude "no versions" incompatibilities for workspace members so we don't say things like (where bird is a workspace member):

Because only bird==0.1.0 is available and bird==0.1.0 depends on anyio==4.3.0, we can conclude that all versions of bird depend on anyio==4.3.0.

Instead, we say:

Because bird==0.1.0 depends on anyio==4.3.0

There's more to be done, more in the flavor of #6066 where we add custom handling for workspace members in the formatter to avoid saying things like "all versions of bird" (which doesn't make sense, because there's only the one local version) and "you require bird" (which could be clearer, i.e., "the workspace includes bird").

Note that 0403e80 isn't actually necessary for this change. I may drop it and just match on NoVersions directly. I'm not sure of the long-term trade-offs here.

@zanieb zanieb added the error messages Messaging when something goes wrong label Aug 14, 2024
}
}

fn iter_tree(
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a display utility, need to find a home for it.

@zanieb
Copy link
Member Author

zanieb commented Aug 14, 2024

These commits are being used in #6092

@zanieb zanieb closed this Aug 14, 2024
zanieb added a commit that referenced this pull request Aug 15, 2024
An extension of #6090 that replaces #6066.

In brief, 

1. Workspace member names are passed to the resolver for no solution
errors
2. There is a new derivation tree pre-processing step that trims
`NoVersion` incompatibilities for workspace members from the derivation
tree. This avoids showing redundant clauses like `Because only
bird==0.1.0 is available and bird==0.1.0 depends on anyio==4.3.0, we can
conclude that all versions of bird depend on anyio==4.3.0.`. As a minor
note, we use a custom incompatibility kind to mark these
incompatibilities at resolution-time instead of afterwards.
3. Root dependencies on workspace members say `your workspace requires
bird` rather than `you require bird`
4. Workspace member package display omits the version, e.g., `bird`
instead of `bird==0.1.0`
5. Instead of reporting a workspace member as unusable we note that its
requirements cannot be solved, e.g., `bird's requirements are
unsatisfiable` instead of `bird cannot be used`.
6. Instead of saying `your requirements are unsatisfiable` we say `your
workspace's requirements are unsatisfiable` when in a workspace, since
we're not in a "provide direct requirements" paradigm.

As an annoying but minor implementation detail, `PackageRange` now
requires access to the `PubGrubReportFormatter` so it can determine if
it is formatting a workspace member or not. We could probably improve
the abstractions in the future.

As a follow-up, we should additional special casing for "single project"
workspaces to avoid mention of the workspace concept in simple projects.
However, it looks like this will require additional tree manipulations
so I'm going to keep it separate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

error messages Messaging when something goes wrong

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant