Skip to content

Commit 414d9e3

Browse files
committed
Auto merge of #12722 - lovesegfault:validate-pkg-root, r=weihanglo
refactor(TomlManifest): fail when package_root is not a directory ### What does this PR try to resolve? Currently, if you're trying to use `TomlManifest::to_real_manifest`, and you pass in something incorrect as the `package_root`, such as the path to the package's manifest, you will get a weird error that looks like this: ``` can't find library `dummy_lib`, rename file to `src/lib.rs` or specify lib.path ``` This is not very helpful, so this change makes us check that `package_root` is a directory, and reports an error early on if it isn't.
2 parents 5bf83d8 + c30151b commit 414d9e3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,13 @@ impl TomlManifest {
18371837
}
18381838
}
18391839

1840+
if !package_root.is_dir() {
1841+
bail!(
1842+
"package root '{}' is not a directory",
1843+
package_root.display()
1844+
);
1845+
};
1846+
18401847
let mut nested_paths = vec![];
18411848
let mut warnings = vec![];
18421849
let mut errors = vec![];

0 commit comments

Comments
 (0)