Skip to content

workspaces: overzealous native library dependency conflicting #7880

Open
@nagisa

Description

@nagisa

Problem

I have a workspace with multiple crates, but for brevity purposes, consider this workspace:

[workspace]
members = [
    "brand_new",
    "old_rusty",
]

These two output a binary executable and don’t depend on each other at all. They have the following dependencies:

brand_new: ring v0.16
old_rusty: ring v0.13

And both versions of ring, in turn, specify links="ring-asm".

Trying to cargo update this workspace will then fail with the following error:

error: failed to select a version for `ring`.
    ... required by package `brand_new v0.0.1 (/tmp/foo/brand_new)`
versions that meet the requirements `^0.16` are: 0.16.11, 0.16.10, 0.16.9, 0.16.7, 0.16.6, 0.16.5, 0.16.4, 0.16.3, 0.16.2, 0.16.1, 0.16.0

the package `ring` links to the native library `ring-asm`, but it conflicts with a previous package which links to `ring-asm` as well:
package `ring v0.13.5`
    ... which is depended on by `old_rusty v0.0.1 (/tmp/foo/old_rusty)`

failed to select a version for `ring` which could resolve this conflict

There's no actual conflict here, however, and not using a workspace would make it work just fine. Whether that’s a good-enough of a workaround is dubious, though.

Steps

  1. Copy the setup from this gist: https://gist.github.com/nagisa/ca95a787c25ba27a73eb3662c85016b2
  2. Run cargo update

Possible Solution(s)

Do not conflict when a particular workspace crate links to just one links dependency. Care must be taken, however, to ensure that we still do conflict when we’d end up pulling multiple links crates into the same binary.

Notes

Output of cargo version: not relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linksArea: `links` native library links settingA-workspacesArea: workspacesC-bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions