From 8acf97536c1b76591543e2a516729928de14d033 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 12 Sep 2023 22:58:03 +0200 Subject: [PATCH] Fix root detection without workspace --- lockfile_generator/src/cargo.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lockfile_generator/src/cargo.rs b/lockfile_generator/src/cargo.rs index 40023c238..9f70be140 100644 --- a/lockfile_generator/src/cargo.rs +++ b/lockfile_generator/src/cargo.rs @@ -13,8 +13,9 @@ pub struct Cargo; impl Generator for Cargo { fn lockfile_path(&self, manifest_path: &Path) -> Result { let cargo_config = Config::default()?; + let workspace_manifest = core::find_workspace_root(manifest_path, &cargo_config)?; let root_manifest = - core::find_workspace_root(manifest_path, &cargo_config)?.unwrap_or_default(); + workspace_manifest.as_ref().map(PathBuf::as_path).unwrap_or(manifest_path); let workspace_root = root_manifest .parent() .ok_or_else(|| Error::InvalidManifest(root_manifest.to_path_buf()))?;