Skip to content

Updating Cargo.lock can result in dependency cycle #65014

@mati865

Description

@mati865
Member

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

Activity

alexcrichton

alexcrichton commented on Oct 2, 2019

@alexcrichton
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

alexcrichton commented on Oct 2, 2019

@alexcrichton
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

mati865 commented on Oct 2, 2019

@mati865
MemberAuthor

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

added a commit that references this issue on Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @alexcrichton@mati865

        Issue actions

          Updating Cargo.lock can result in dependency cycle · Issue #65014 · rust-lang/rust