Skip to content

Hakari creates a cyclic dependency. #499

@TroyKomodo

Description

@TroyKomodo
cargo hakari generate
info: contents updated
error: cyclic package dependency: package `scuffle-workspace-hack v0.1.0 (/home/troy/github/scuffle/scuffle/crates/workspace-hack)` depends on itself. Cycle:
package `scuffle-workspace-hack v0.1.0 (/home/troy/github/scuffle/scuffle/crates/workspace-hack)`
    ... which satisfies dependency `scuffle-workspace-hack = "^0.1.0"` (locked to 0.1.0) of package `tinc-cel v0.0.1`
    ... which satisfies dependency `tinc-cel = "^0.0.1"` (locked to 0.0.1) of package `scuffle-workspace-hack v0.1.0 (/home/troy/github/scuffle/scuffle/crates/workspace-hack)`
    ... which satisfies dependency `scuffle-workspace-hack = "^0.1.0"` (locked to 0.1.0) of package `scuffle-changelog v0.1.0 (/home/troy/github/scuffle/scuffle/crates/changelog)`
    ... which satisfies dependency `scuffle-changelog = "^0.1"` (locked to 0.1.0) of package `nutype-enum v0.1.4 (/home/troy/github/scuffle/scuffle/crates/nutype_enum)`
Error: 
   0: updating Cargo.lock failed
   1: command ["/home/troy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo", "--color=auto", "tree"] exited with code 101

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

I think the issue comes from the way I setup my workspace.

We have a patch for each workspace member https://github.com/ScuffleCloud/scuffle/blob/69a08df806cc999bc59e3371e9b094fdb7d0d7e3/Cargo.toml#L52

The reason we do this is because we want to be able to change the version the crates depend on without forcing them to jump to the latest.

Real example:

scuffle-h264 depends on scuffle-bytes-util
scuffle-flv depends on scuffle-bytes-util

If we add something to scuffle-byte-util and then use that something in scuffle-h264 we need to bump the peer dependency scuffle-bytes-util in scuffle-h264 to match the new version where the something was released. We don't need to bump scuffle-flv's version since it does not need the new feature.

Our options are:

  • Use workspace deps. scuffle-bytes-util.workspace = true (versions are controlled in the workspace manifest and we cant override it on a per crate basis ☹ )
  • Have the paths in every single crate scuffle-bytes-util = { path = "../../../bytes-util" } (really ugly and annoying)
  • use patches (the one we picked) scuffle-bytes-util = "0.1.2" with a patch override.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions