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

Fix --package <non-existent> --workspace #14755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cargo/util/command_prelude.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We suggest a PR coming with some tests to show how the behavior changed. It is better if we can have a commit capturing the current behavior, followed by the fix and the test change with CI passing.

Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,14 @@ Run `{cmd}` to see possible targets."
workspace: Option<&Workspace<'_>>,
profile_checking: ProfileChecking,
) -> CargoResult<CompileOptions> {
let spec = self.packages_from_flags()?;
let w = self.flag("workspace");
let mut all = w || self.flag("all");
let package = self._values_of("package");
if w && !package.is_empty() {
all = false;
}
Comment on lines +693 to +696
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior and is not even proposed in the original issue.

I would recommend starting with a warning first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I am again, sorry for my lack of seriousness, i have a small question. issuing an error when the user uses --package <package> & --workspace / --all would be good for this issue? I have the impression that the fact that the package doesn't exist doesn't change anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a workspace and test it out. Before this patch, cargo b -p foo --workspace works without error. After this, it reports foo matching nothing. This should be a warning first, not a hard error.


let spec = Packages::from_flags(all, self._values_of("exclude"), package)?;
let mut message_format = None;
let default_json = MessageFormat::Json {
short: false,
Expand Down