Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo new workspace error from toml edit #8118

Closed
ralpha opened this issue Apr 15, 2020 · 2 comments · Fixed by #8119
Closed

Cargo new workspace error from toml edit #8118

ralpha opened this issue Apr 15, 2020 · 2 comments · Fixed by #8119
Labels
C-bug Category: bug

Comments

@ralpha
Copy link

ralpha commented Apr 15, 2020

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

  1. Create a package
  2. Create a lib
  3. Edit Cargo.toml (add workspace.members section)
  4. Create a lib
  5. 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!

@ehuss
Copy link
Contributor

ehuss commented Apr 16, 2020

Thanks for the report! Looks like it was reporting the message using the debug display which if RUST_BACKTRACE is set also displays a backtrace. Posted a small fix at #8119.

@ralpha
Copy link
Author

ralpha commented Apr 16, 2020

Perfect, if that solves the issue this can be closed.
And quick response time here 😄

@bors bors closed this as completed in ebda506 Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants