diff --git a/crates/cargo_utils/src/workspace_members.rs b/crates/cargo_utils/src/workspace_members.rs index 401ead5c98..69acc7cef5 100644 --- a/crates/cargo_utils/src/workspace_members.rs +++ b/crates/cargo_utils/src/workspace_members.rs @@ -1,13 +1,13 @@ -use anyhow::Context; use cargo_metadata::{Metadata, Package}; use std::path::Path; -pub fn get_manifest_metadata(manifest_path: &Path) -> anyhow::Result { +pub fn get_manifest_metadata( + manifest_path: &Path, +) -> Result { cargo_metadata::MetadataCommand::new() .no_deps() .manifest_path(manifest_path) .exec() - .with_context(|| format!("invalid manifest {manifest_path:?}")) } /// Lookup all members of the current workspace diff --git a/crates/release_plz/src/args/repo_command.rs b/crates/release_plz/src/args/repo_command.rs index a055f455f3..5c9506b8fe 100644 --- a/crates/release_plz/src/args/repo_command.rs +++ b/crates/release_plz/src/args/repo_command.rs @@ -16,7 +16,16 @@ pub trait RepoCommand { } fn cargo_metadata(&self) -> anyhow::Result { - cargo_utils::get_manifest_metadata(&self.project_manifest()) + let manifest = &self.project_manifest(); + cargo_utils::get_manifest_metadata(manifest).map_err(|e| match e { + cargo_metadata::Error::CargoMetadata { stderr } => { + let stderr = stderr.trim(); + anyhow::anyhow!("{stderr}. Use --project-manifest to specify the path to the manifest file if it's not in the current directory.") + } + _ => { + anyhow::anyhow!(e) + } + }) } fn get_repo_url(&self, config: &Config) -> anyhow::Result {