Skip to content

Have verify-project print out the cause of error #10661

Closed as not planned
Closed as not planned
@Muscraft

Description

@Muscraft

Problem

Currently cargo verify-project only prints out {"invalid": "error msg"} in the event of an error. While this does show there was an error it does not say what caused the error. When trying to verify that the changes to your manifest are okay this can be hard since you cannot see what went wrong. it also seems odd to not show the full error such as cargo check would.

cargo +nightly check

error: failed to load manifest for workspace member `{path}/temp`

Caused by:
  failed to parse manifest at `{path}/temp/Cargo.toml`

Caused by:
  error inheriting `categories` from workspace root manifest's `workspace.package.categories`

Caused by:
  `workspace.package.categories` was not defined

vs
cargo +nightly verify-project

{"invalid":"failed to load manifest for workspace member `{path}/temp`"}

Proposed Solution

Add the error chain to the output when there is an error or only when --verbose is set. Another solution would be to print out the error chain in a human-readable format when --format 1 is set.

Example for cargo verify-project --verbose

{
  "invalid":"failed to load manifest for workspace member `{path}/temp`",
  "causes": [
    "failed to parse manifest at `{path}/temp/Cargo.toml`",
    "error inheriting `categories` from workspace root manifest's `workspace.package.categories`",
    "`workspace.package.categories` was not defined"
  ]
}

Example for cargo verify-project --verbose --format 1

error: failed to load manifest for workspace member `{path}/temp`

Caused by:
  failed to parse manifest at `{path}/temp/Cargo.toml`

Caused by:
  error inheriting `categories` from workspace root manifest's `workspace.package.categories`

Caused by:
  `workspace.package.categories` was not defined

Notes

This was found while trying to find a way for testers of workspace inheritance to verify that their manifests are okay without running a heavier command. It would be nice if there was a way to print out what caused the error not only that there was an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-verify-projectS-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