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

Updating Cargo.lock can result in dependency cycle #65014

Closed
mati865 opened this issue Oct 2, 2019 · 3 comments
Closed

Updating Cargo.lock can result in dependency cycle #65014

mati865 opened this issue Oct 2, 2019 · 3 comments

Comments

@mati865
Copy link
Contributor

mati865 commented Oct 2, 2019

Bumping few packages can result in dependency cycle.

Single command reproducer:

$ cargo update --aggressive -p cargo            
    Updating crates.io index
    Updating git repository `https://github.com/rust-lang/cargo`
error: cyclic package dependency: package `compiler_builtins v0.1.19` depends on itself. Cycle:
package `compiler_builtins v0.1.19`
    ... which is depended on by `alloc v0.0.0 (/home/mateusz/Projects/rust/rust/src/liballoc)`
    ... which is depended on by `panic_unwind v0.0.0 (/home/mateusz/Projects/rust/rust/src/libpanic_unwind)`
    ... which is depended on by `std v0.0.0 (/home/mateusz/Projects/rust/rust/src/libstd)`
    ... which is depended on by `proc_macro v0.0.0 (/home/mateusz/Projects/rust/rust/src/libproc_macro)`
    ... which is depended on by `test v0.0.0 (/home/mateusz/Projects/rust/rust/src/libtest)`

cc @alexcrichton

@alexcrichton
Copy link
Member

Looks like Cargo is correct here but it's a bad error message. I'll work on the error message independently, but the real error is:

error: cyclic package dependency: package `compiler_builtins v0.1.19` depends on itself. Cycle:
package `compiler_builtins v0.1.19`
    ... which is depended on by `cfg-if v0.1.10`
    ... which is depended on by `getrandom v0.1.12`
    ... which is depended on by `jobserver v0.1.17`
    ... which is depended on by `cc v1.0.45`
    ... which is depended on by `compiler_builtins v0.1.19`
    ... which is depended on by `alloc v0.0.0 (/home/alex/code/rust2/src/liballoc)`

This happens because cc now has the parallel feature enabled when updating libgit2-sys. I'm gonna close this since I'm about to fix the error message in Cargo and otherwise I believe this is a legitimate error.

@alexcrichton
Copy link
Member

Note that this is an instance of rust-lang/cargo#4866 where the host cfg-if shouldn't have rustc-dep-of-std enabled, but it does.

@mati865
Copy link
Contributor Author

mati865 commented Oct 2, 2019

Oh it's nasty one. Thanks for the explanation, it's clear now.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Oct 7, 2019
First reported in rust-lang/rust#65014 it looks like our error message
on cyclic dependencies may be confusing at times. It looks like this is
an issue because there are multiple paths through a graph for a
dependency, so using the generic `path_to_top` function isn't producing
the most useful path for this purpose.

We're already walking the graph though, so this commit adds an extra
parameter which collects the list of packages we've visited so far to
produce a hopefully always-accurate error message showing the chain of
dependencies end-to-end for what depends on what.
bors added a commit to rust-lang/cargo that referenced this issue Oct 8, 2019
Improve error message for cyclic dependencies

First reported in rust-lang/rust#65014 it looks like our error message
on cyclic dependencies may be confusing at times. It looks like this is
an issue because there are multiple paths through a graph for a
dependency, so using the generic `path_to_top` function isn't producing
the most useful path for this purpose.

We're already walking the graph though, so this commit adds an extra
parameter which collects the list of packages we've visited so far to
produce a hopefully always-accurate error message showing the chain of
dependencies end-to-end for what depends on what.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants