Skip to content

When build fails, print dependency graph path leading to failure #16196

@stepancheg

Description

@stepancheg

Problem

I'm running cargo build --bin foo (with cross-compilation, custom compiler, large workspace, feature flags, etc etc).

Build fails:

...
   Compiling openssl-sys v0.9.110
error: failed to run custom build command for `openssl-sys v0.9.110`
...
warning: build failed, waiting for other jobs to finish...

Why was openssl even compiled? It is not supposed to be in the dependency tree. I run cargo tree -p foo-pkg, and openssl-sys it is nowhere there. I'm stuck. (I'm not asking for help with openssl here, this is an illustration.)

Proposed Solution

When build fails, print a graph path leading to the dependency that failed to build. Like this:

   Compiling openssl-sys v0.9.110
error: failed to run custom build command for `openssl-sys v0.9.110`
...
openssl-sys was compiled because it is dependency of openssl
... which is dependency of native-tls
... which is a build dependency of aaa
... which is a dependency of foo-pkg

warning: build failed, waiting for other jobs to finish...

Notes

buck2 does something similar for every error: it prints dependency graph path leading to an error, for example:

Error running analysis for `root//:main (prelude//platforms:default#f6691640831d48dd)`

Caused by:
    0: Error looking up configured node root//:main (prelude//platforms:default#f6691640831d48dd)
    1: Error looking up configured node toolchains//:java (prelude//platforms:default#f6691640831d48dd) (prelude//platforms:default#f6691640831d48dd)
    2: looking up unconfigured target node `toolchains//:java`
    3: Unknown target `java` from package `toolchains//`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsA-diagnosticsArea: Error and warning messages generated by Cargo itself.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-treeS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions