cargo-workspaces icon indicating copy to clipboard operation
cargo-workspaces copied to clipboard

cargo workspaces create does not add to workspace manifest?

Open ColonelThirtyTwo opened this issue 2 years ago • 0 comments

I would expect cargo workspaces create to add the newly created crate to the current workspace. However it does not seem to do that; the workspace Cargo.toml remains empty. Additionally, the crate has its own git repo inside of it, which is inappropriate for most setups where the entire workspace should be in the git repo.

ol@col-laptop-asus ~> mkdir cargo-ws-test
col@col-laptop-asus ~> cd cargo-ws-test/
col@col-laptop-asus ~/cargo-ws-test> cargo workspaces init .
info initialized .
col@col-laptop-asus ~/cargo-ws-test> cargo workspaces create
error: The following required arguments were not provided:
    <PATH>

USAGE:
    cargo workspaces create [OPTIONS] <PATH>

For more information try --help
col@col-laptop-asus ~/cargo-ws-test [2]> cargo workspaces create test-lib
✔ Name of the crate · test-lib
✔ Type of the crate · library
✔ Rust edition · 2021
warning: compiling this new package may not work due to invalid workspace configuration

current package believes it's in a workspace when it's not:
current:   /home/col/cargo-ws-test/test-lib/Cargo.toml
workspace: /home/col/cargo-ws-test/Cargo.toml

this may be fixable by adding `test-lib` to the `workspace.members` array of the manifest located at: /home/col/cargo-ws-test/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.
     Created library `test-lib` package
info success ok
col@col-laptop-asus ~/cargo-ws-test> cat Cargo.toml 
[workspace]
members = []
ol@col-laptop-asus ~/cargo-ws-test> ls ./test-lib/ -alh
total 24K
drwxr-xr-x 4 col col 4.0K Jun 27 13:22 ./
drwxr-xr-x 3 col col 4.0K Jun 27 13:22 ../
-rw-r--r-- 1 col col  176 Jun 27 13:22 Cargo.toml
drwxr-xr-x 6 col col 4.0K Jun 27 13:22 .git/
-rw-r--r-- 1 col col   19 Jun 27 13:22 .gitignore
drwxr-xr-x 2 col col 4.0K Jun 27 13:22 src/
col@col-laptop-asus ~/cargo-ws-test> cargo workspaces --version
cargo-workspaces 0.2.34

Am I misunderstanding the workflow for cargo-workspaces? This should be done automatically.

PS the crate name should be inferred from the path - it's annoying to specify it twice.

ColonelThirtyTwo avatar Jun 27 '22 17:06 ColonelThirtyTwo