-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Error when creating new lib after editing Cargo.toml file. Small issue, mostly visual.
Problem
I used the $ cargo new df_st_db --lib
where 'df_st_db' is the name of the workspace.
This gave me the following result:
$ cargo new df_st_db --lib
warning: compiling this new crate may not work due to invalid workspace configuration
current package believes it's in a workspace when it's not:
current: /...redacted.../df_st_db/Cargo.toml
workspace: /...redacted.../Cargo.toml
this may be fixable by adding `df_st_db` to the `workspace.members` array of the manifest located at: /...redacted.../Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
Stack backtrace:
0: cargo::core::workspace::Workspace::new
1: cargo::ops::cargo_new::mk
2: cargo::ops::cargo_new::new
3: cargo::commands::new::exec
4: cargo::cli::main
5: cargo::main
6: std::rt::lang_start::{{closure}}
7: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
std::panicking::try::do_call
at src/libstd/panicking.rs:305
8: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
9: std::panicking::try
at src/libstd/panicking.rs:281
std::panic::catch_unwind
at src/libstd/panic.rs:394
std::rt::lang_start_internal
at src/libstd/rt.rs:51
10: main
11: __libc_start_main
12: <unknown>
Created library `df_st_db` package
This gave the backtrace above, although I see no direct error.
I was adding a workspace to a project that already has 5 more workspaces.
These we created in the same way, but no error there.
There does NOT seem to be any issues with the creation of the package/workspace. All files are fine and exactly as expacted.
Steps
- Create a package
- Create a lib
- Edit Cargo.toml (add workspace.members section)
- Create a lib
- Stack backtrace in output
Here is the output I could reproduce it with: (execute this in terminal, somewhere in an empty folder is best)
cargo new df_test
cd df_test/
cargo new df_core --lib
cat > Cargo.toml << EOF
[package]
name = "df_test"
version = "0.1.0"
authors = ["user <>"]
edition = "2018"
[workspace]
members = [
"df_core",
]
[dependencies]
EOF
cargo new df_st_db --lib
Possible Solution(s)
The problem is with the workspace.members section in the toml file. Maybe it tries to edit this section?
If I do not edit the toml file (aka do not execute the cat
lines above), I don't get any warnings.
Notes
Output of cargo version
:
$ cargo version
cargo 1.42.0 (86334295e 2020-01-31)
$ uname -a
Linux Ralpha 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)
First issue I had with Cargo and still ♥ Cargo, great job everyone!