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: Confusing error message about adding to a workspace #13985

Closed
ehuss opened this issue May 30, 2024 · 4 comments · Fixed by #13987
Closed

cargo new: Confusing error message about adding to a workspace #13985

ehuss opened this issue May 30, 2024 · 4 comments · Fixed by #13987
Labels
A-workspaces Area: workspaces C-bug Category: bug Command-new S-triage Status: This issue is waiting on initial triage.

Comments

@ehuss
Copy link
Contributor

ehuss commented May 30, 2024

Problem

cargo add seems to generate a confusing message about adding a package to a workspace when there is no workspace, and it isn't actually added to the workspace.

Steps

  1. cargo new foo
  2. cd foo
  3. cargo new bar
    This prints: Adding bar as member of workspace at /Temp/foo
  4. cargo metadata | jq .workspace_members
    Notice that bar was not added as a workspace member. Also notice that foo's Cargo.toml was not modified.

Possible Solution(s)

Should not print a message about adding bar to a workspace when it isn't actually added.

Notes

No response

Version

cargo 1.80.0-nightly (431db31d0 2024-05-28)
release: 1.80.0-nightly
commit-hash: 431db31d0dbeda320caf8ef8535ea48eb3093407
commit-date: 2024-05-28
host: aarch64-apple-darwin
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0 (sys:0.4.72+curl-8.6.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.5.0 [64-bit]
@ehuss ehuss added C-bug Category: bug A-workspaces Area: workspaces Command-add S-triage Status: This issue is waiting on initial triage. labels May 30, 2024
@epage
Copy link
Contributor

epage commented May 30, 2024

I assume this issue should be about cargo new and not cargo add?

I also assume some steps are missing and that to reproduce, we need to cd into specific directories (I did run the steps as-is and couldn't reproduce it). Could you specify where the person should be at each step?

@epage
Copy link
Contributor

epage commented May 30, 2024

I'm assuming Steps (2) and (3) are supposed to be done after cd foo.

We even have a test case showing this problem: tests/testsuite/cargo_new/add_members_to_non_workspace/. Unsure how we missed this going by.

@ehuss ehuss changed the title cargo add: Confusing error message about adding to a workspace cargo new: Confusing error message about adding to a workspace May 30, 2024
@ehuss
Copy link
Contributor Author

ehuss commented May 30, 2024

Yes, sorry, it is cargo new and there is a missing step. Wrote this in too much of a hurry trying to get back to where I was.

@linyihai
Copy link
Contributor

Unsure how we missed this going by.

It's my bad, I'm so sorry for that. Can't remember why I forced this change without checking it.

bors added a commit that referenced this issue May 31, 2024
fix(new): Dont say were adding to a workspace when a regular package is in root

Fixes #13985
@bors bors closed this as completed in 26c1678 May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-workspaces Area: workspaces C-bug Category: bug Command-new S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants