Skip to content

Improve error message displayed when a string is used instead of an array for 'authors' in the manifest #10942

Closed
@ptdecker

Description

@ptdecker

Problem

Currently, if one uses a string instead of an array of strings as the value for the authors field an error message is displayed which is not helpful for a new Rust developer to identify the cause of the problem.

Example of an incorrect Cargo.toml:

[package]
name = "alenandbarb"
version = "0.1.0"
edition = "2021"
authors = "Todd Decker"
description = "A toy application for crustatian exploration along network and applications seafloor"

[features]
desktop = ["dioxus/desktop"]
web = ["dioxus/web"]

[dependencies]
dioxus = "0.2.4"

The error message displayed is:

Execution failed (exit code 101).
/Users/ptdecker/.cargo/bin/cargo metadata --verbose --format-version 1 --all-features
stdout : error: failed to parse manifest at `/Users/ptdecker/CLionProjects/alenandbarb/Cargo.toml`

Caused by:
  data did not match any variant of untagged enum MaybeWorkspace for key `package.authors`

stderr : 

Proposed Solution

An error message along the lines of the below would be more informative:

Execution failed (exit code 101).
/Users/ptdecker/.cargo/bin/cargo metadata --verbose --format-version 1 --all-features
stdout : error: failed to parse manifest at `/Users/ptdecker/CLionProjects/alenandbarb/Cargo.toml`

Caused by:
  value of `package.authors` is a string, while an array was expected

stderr : 

Notes

I also submitted the PR below to update the Cargo documentation to better explain the requirements of the field:

#10938

@epage saw my post on the forum about my problem (link) and suggested that I also submit an issue to improve the error message itself.

Thank you

P. Todd Decker

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-manifestArea: Cargo.toml issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions