Skip to content

Commit de31a34

Browse files
committed
Auto merge of #8321 - hbina:issue_7596, r=alexcrichton
Better error message when passing in relative path to Workspace::new Fixes #7596
2 parents e9d7af4 + 84f1dc1 commit de31a34

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cargo/core/workspace.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,16 @@ impl<'cfg> Workspace<'cfg> {
145145
pub fn new(manifest_path: &Path, config: &'cfg Config) -> CargoResult<Workspace<'cfg>> {
146146
let mut ws = Workspace::new_default(manifest_path.to_path_buf(), config);
147147
ws.target_dir = config.target_dir()?;
148-
ws.root_manifest = ws.find_root(manifest_path)?;
148+
149+
if manifest_path.is_relative() {
150+
anyhow::bail!(
151+
"manifest_path:{:?} is not an absolute path. Please provide an absolute path.",
152+
manifest_path
153+
)
154+
} else {
155+
ws.root_manifest = ws.find_root(manifest_path)?;
156+
}
157+
149158
ws.find_members()?;
150159
ws.resolve_behavior = match ws.root_maybe() {
151160
MaybePackage::Package(p) => p.manifest().resolve_behavior(),

0 commit comments

Comments
 (0)