From 2e2ae6038d0650fb229d379b7a27d21035a3e1d7 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 29 Oct 2023 19:19:31 +0000 Subject: [PATCH] update error message --- tooling/nargo_toml/src/errors.rs | 2 +- tooling/nargo_toml/src/semver.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tooling/nargo_toml/src/errors.rs b/tooling/nargo_toml/src/errors.rs index 23750dcaed7..fdbdc317bf9 100644 --- a/tooling/nargo_toml/src/errors.rs +++ b/tooling/nargo_toml/src/errors.rs @@ -73,7 +73,7 @@ pub enum ManifestError { #[derive(Error, Debug, PartialEq, Eq, Clone)] pub enum SemverError { - #[error("Incompatible compiler version in package {package_name}. Required version is {required_compiler_version} but the compiler version is {compiler_version_found}")] + #[error("Incompatible compiler version in package {package_name}. Required compiler version is {required_compiler_version} but the compiler version is {compiler_version_found}.\n Update the compiler_version field in Nargo.toml to >={compiler_version_found} or compile this project with version {compiler_version_found}")] IncompatibleVersion { package_name: CrateName, required_compiler_version: String, diff --git a/tooling/nargo_toml/src/semver.rs b/tooling/nargo_toml/src/semver.rs index 28847330e18..11fe60d6c70 100644 --- a/tooling/nargo_toml/src/semver.rs +++ b/tooling/nargo_toml/src/semver.rs @@ -39,7 +39,7 @@ pub(crate) fn semver_check_package( return Err(SemverError::IncompatibleVersion { package_name: package.name.clone(), required_compiler_version: version.clone(), - compiler_version_found: compiler_version.to_string(), + compiler_version_found: strip_build_meta_data(compiler_version), }); }; } @@ -56,6 +56,13 @@ pub(crate) fn semver_check_package( Ok(()) } +// Strip the build meta data from the version string since it is ignored by semver. +fn strip_build_meta_data(version: &Version) -> String { + let version_string = version.to_string(); + let mut split = version_string.split('+'); + split.next().expect("split was called on an empty string").to_string() +} + #[cfg(test)] mod tests { use std::{collections::BTreeMap, path::PathBuf, str::FromStr};