Skip to content

Commit 56274af

Browse files
committed
fix confusing error for virtual manifest with no member
1 parent 4e5bfc9 commit 56274af

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/cargo/core/workspace.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ impl<'cfg> Workspace<'cfg> {
169169
/// indicating that something else should be passed.
170170
pub fn current(&self) -> CargoResult<&Package> {
171171
self.current_opt().ok_or_else(||
172-
format!("manifest path `{}` is a virtual manifest, but this \
173-
command requires running against an actual package in \
174-
this workspace", self.current_manifest.display()).into()
172+
format!("manifest path `{}` contains no package: The manifest is virtual, \
173+
and the workspace has no members.", self.current_manifest.display()).into()
175174
)
176175
}
177176

tests/workspaces.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,20 +696,13 @@ fn virtual_build_no_members() {
696696
let p = project("foo")
697697
.file("Cargo.toml", r#"
698698
[workspace]
699-
"#)
700-
.file("bar/Cargo.toml", r#"
701-
[project]
702-
name = "bar"
703-
version = "0.1.0"
704-
authors = []
705-
"#)
706-
.file("bar/src/main.rs", "fn main() {}");
699+
"#);
707700
p.build();
708701
assert_that(p.cargo("build"),
709702
execs().with_status(101)
710703
.with_stderr("\
711-
error: manifest path `[..]` is a virtual manifest, but this command \
712-
requires running against an actual package in this workspace
704+
error: manifest path `[..]` contains no package: The manifest is virtual, \
705+
and the workspace has no members.
713706
"));
714707
}
715708

0 commit comments

Comments
 (0)