From 9907039c99d9ce2ced2e6c81c7328a04a461452b Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 3 Jun 2020 11:13:22 -0400 Subject: [PATCH 1/2] Attemtping to solve Workspace using relative path. --- src/cargo/core/workspace.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 5931a9a5c7f..bf2ca3d330c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -145,7 +145,13 @@ impl<'cfg> Workspace<'cfg> { pub fn new(manifest_path: &Path, config: &'cfg Config) -> CargoResult> { let mut ws = Workspace::new_default(manifest_path.to_path_buf(), config); ws.target_dir = config.target_dir()?; - ws.root_manifest = ws.find_root(manifest_path)?; + + if manifest_path.is_relative() { + ws.root_manifest = Some(std::env::current_dir()?); + } else { + ws.root_manifest = ws.find_root(manifest_path)?; + } + ws.find_members()?; ws.resolve_behavior = match ws.root_maybe() { MaybePackage::Package(p) => p.manifest().resolve_behavior(), From 84f1dc1b5990068e2df1f0fec3656e55ed2c4b9f Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 3 Jun 2020 11:38:34 -0400 Subject: [PATCH 2/2] Passing a relative path to Workspace now bails with proper message. Previously, this failure will return an unhelpful warning. This commit adds an error message saying that the argument for `manifest_path` must be an absolute path. --- src/cargo/core/workspace.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index bf2ca3d330c..c356f65add1 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -147,7 +147,10 @@ impl<'cfg> Workspace<'cfg> { ws.target_dir = config.target_dir()?; if manifest_path.is_relative() { - ws.root_manifest = Some(std::env::current_dir()?); + anyhow::bail!( + "manifest_path:{:?} is not an absolute path. Please provide an absolute path.", + manifest_path + ) } else { ws.root_manifest = ws.find_root(manifest_path)?; }