diff --git a/crates/rattler_conda_types/src/version_spec/constraint.rs b/crates/rattler_conda_types/src/version_spec/constraint.rs index c041e5282..31897b126 100644 --- a/crates/rattler_conda_types/src/version_spec/constraint.rs +++ b/crates/rattler_conda_types/src/version_spec/constraint.rs @@ -236,9 +236,12 @@ mod test { Constraint::from_str("=1.2.*", Strict), Err(ParseConstraintError::GlobVersionIncompatibleWithOperator(_)) ); - assert_matches!( - Constraint::from_str("!=1.2.*", Strict), - Err(ParseConstraintError::GlobVersionIncompatibleWithOperator(_)) + assert_eq!( + Constraint::from_str("!=1.2.*", Lenient), + Ok(Constraint::StrictComparison( + StrictRangeOperator::NotStartsWith, + Version::from_str("1.2").unwrap(), + )) ); assert_matches!( Constraint::from_str(">=1.2.*", Strict), diff --git a/crates/rattler_conda_types/src/version_spec/parse.rs b/crates/rattler_conda_types/src/version_spec/parse.rs index 93dee07a9..00a4ee12c 100644 --- a/crates/rattler_conda_types/src/version_spec/parse.rs +++ b/crates/rattler_conda_types/src/version_spec/parse.rs @@ -210,7 +210,13 @@ fn logical_constraint_parser( )), Lenient, ) => VersionOperators::Range(RangeOperator::GreaterEquals), - ("*" | ".*", Some(VersionOperators::Exact(EqualityOperator::NotEquals)), Lenient) => { + ( + "*" | ".*", + Some(VersionOperators::Exact(EqualityOperator::NotEquals)), + Lenient | Strict, + ) => { + // !=1.2.3.* is the only way to express a version should not start with 1.2.3 so + // even in strict mode we allow this. VersionOperators::StrictRange(StrictRangeOperator::NotStartsWith) } ("*" | ".*", Some(op), Lenient) => {