Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GlenDC opened this issue Nov 30, 2023 · 2 comments
Closed
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@GlenDC
Copy link

GlenDC commented Nov 30, 2023

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]
@GlenDC GlenDC added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Nov 30, 2023
@ehuss
Copy link
Contributor

ehuss commented Nov 30, 2023

Thanks for the report! This was recently fixed via #12977.

The error message still might not be entirely intuitive, but I think we have other issues for tracking better conflict messages.

    Updating crates.io index
error: failed to select a version for `rustls-pki-types`.
    ... required by package `rustls v0.22.0-alpha.6`
    ... which satisfies dependency `rustls = "^0.22.0-alpha.6"` of package `rama-rt v0.2.0 (/Users/eric/Temp/z32/rama/rama-rt)`
    ... which satisfies path dependency `rama-rt` (locked to 0.2.0) of package `rama v0.2.0 (/Users/eric/Temp/z32/rama)`
    ... which satisfies path dependency `rama` (locked to 0.2.0) of package `rama-rt-macros v0.2.0 (/Users/eric/Temp/z32/rama/rama-rt-macros)`
versions that meet the requirements `^0.2.2` are: 0.2.3, 0.2.2

all possible versions conflict with previously selected packages.

  previously selected package `rustls-pki-types v0.2.1`
    ... which satisfies dependency `pki-types = "=0.2.1"` of package `rama v0.2.0 (/Users/eric/Temp/z32/rama)`
    ... which satisfies path dependency `rama` (locked to 0.2.0) of package `rama-rt-macros v0.2.0 (/Users/eric/Temp/z32/rama/rama-rt-macros)`

failed to select a version for `rustls-pki-types` which could resolve this conflict

Closing as a duplicate of #12941.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@GlenDC
Copy link
Author

GlenDC commented Nov 30, 2023

Thanks @ehuss I can confirm that that now works nicely indeed. When I update my nightly version I also get this nice output. This would have been enough of an error messages for me to be able to resolve it myself (the dep issue).

Thanks team, like always! Awesome work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants