Skip to content

non descrriptive output by cargo for dependencies with cycles in their path #13079

@GlenDC

Description

@GlenDC

Problem

I noticed thus bug originally in the context of Rustls, and that's where I first opened an issue (rustls/rustls#1647).

Turns out that it wasn't an issue with them, but something in my own dependency graph. However, it would have been very hard for me to spot the issue if it wasn't for the help of the rustls maintainers.

Problem with this kind of error is that the only output you get is:

cargo check
    Updating crates.io index
thread 'main' panicked at src/cargo/util/graph.rs:149:20:
the only path was a cycle, no dependency graph has this shape
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Even running RUST_BACKTRACE=1 gives nothing much, just more info about the cargo logic running prior to the panic, but not what the actual issue is.

Steps

  1. clone repo https://github.com/plabayo/rama on commit 39b647692299fc544dde4d66be72b29338d7419f
  2. apply the below diff
  3. enjoy the obscure output
diff --git a/rama-rt/Cargo.toml b/rama-rt/Cargo.toml
index 4d70e24..9dae0c0 100644
--- a/rama-rt/Cargo.toml
+++ b/rama-rt/Cargo.toml
@@ -13,8 +13,8 @@ authors = { workspace = true }
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

 [dependencies]
-rustls = "0.22.0-alpha.4"
+rustls = "0.22.0-alpha.6"
 tokio = { version = "1.33", features = ["net", "io-util", "rt-multi-thread"] }
 tokio-graceful = "0.1"
-tokio-rustls = "0.25.0-alpha.2"
+tokio-rustls = "0.25.0-alpha.4"
 tokio-test = "0.4.3"

Possible Solution(s)

Probably all people facing these issues have an issue that is unique to their dependency tree. So the issue is for sure something local. However right now it is very hard to figure out what that might be, as your change might not be directly related to it.

Even cargo tree fails in those moments.

The thing is it clearly fails because it knows the condition is unexpected. So the resolution might be as simple as just printing the cycle it detects? No need for suggestions I think. If it can just tell me the dependencies involved I (and others) probably would know enough to fix what is going on. But now... well.. now you get nothing.

Notes

My issue is resolved in meanwhile, so there is no urgency here. Filing it more for your information as in general Rust has amazing compiler / tooling feedback. This is the first case I encounter that absolutely tells me nothing (outside of stuff to do with FFI or other unsafe territories).

In fact in my almost a decade of using Rust this is the first time I encounter dependency issues, which is not something I can say for many other languages that have used in the last 2 decades... Thanks Rust team, for everything! You honestly have made an ecosystem that is both pragmatic in use and lovely to use.

Version

cargo version --verbose
cargo 1.76.0-nightly (6790a5127 2023-11-10)
release: 1.76.0-nightly
commit-hash: 6790a5127895debec95c24aefaeb18e059270df3
commit-date: 2023-11-10
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.1.2 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 13.6.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions