Skip to content

cargo init is not working great when creating a new workspace with multiple members #11234

Open

Description

Problem

Got a spurious warning when creating a workspace component with cargo init or cargo new. Expected it to go without issue. See below.

Steps

  1. Created a new workspace with a top-level toml
[workspace]
members = [ "feature-lib", "feature-bin" ]
  1. Then made subdirectories for feature-lib and feature-bin.

  2. Then went to feature-lib and said cargo init --lib.

Got this error message:

warning: compiling this new package may not work due to invalid workspace configuration

failed to load manifest for workspace member `/home/bart/prj/rust/feature-bugs/feature-bin`

Caused by:
  failed to read `/home/bart/prj/rust/feature-bugs/feature-bin/Cargo.toml`

Caused by:
  No such file or directory (os error 2)
     Created library package

The feature-lib toml was created correctly, so the only real issue is the misleading message. When proceeding to feature-bin and running cargo init --bin everything worked normally.

Starting without any new directories and running cargo new --lib feature-lib produced the same error.

Possible Solution(s)

Very low priority to fix, but would be nice to suppress the unavoidable warning message in these cases. Somebody has to be created first. 🙂 . I think it would be sufficient to ignore missing or empty workspace component directories. I'm not sure why this warning exists at all, honestly: what kinds of mistakes does it protect against?

Notes

No response

Version

cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: Debian n/a [64-bit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-documenting-cargo-itselfArea: Cargo's documentationArea: Cargo's documentationC-bugCategory: bugCategory: bugCommand-newE-mediumExperience: MediumExperience: MediumS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions