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
- Created a new workspace with a top-level toml
[workspace]
members = [ "feature-lib", "feature-bin" ]
-
Then made subdirectories for
feature-lib
andfeature-bin
. -
Then went to
feature-lib
and saidcargo 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]