From 6404641249b0680cb863d69b7cfe4dfc682343a7 Mon Sep 17 00:00:00 2001 From: andres Date: Wed, 26 Feb 2025 20:15:52 -0500 Subject: [PATCH] Fix version finding on multiple lines --- build.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index edbb34b6..7b81ca21 100644 --- a/build.rs +++ b/build.rs @@ -197,10 +197,7 @@ fn probe_r_paths() -> io::Result { // Now the library location. On Windows, it depends on the target architecture let library = get_r_library(&r_home); - Ok(InstallationPaths { - r_home, - library, - }) + Ok(InstallationPaths { r_home, library }) } // Parse an R version (e.g. "4.1.2" and "4.2.0-devel") and return the RVersionInfo. @@ -294,13 +291,12 @@ fn get_r_version_from_r(r_paths: &InstallationPaths) -> Result parse_r_version(v.to_string()), - None => Err(EnvVarError::InvalidROutput("Cannot find R version")), - } + out.lines() + .map(|v| parse_r_version(v.to_string())) + .find(|r| r.is_ok()) + .ok_or_else(|| EnvVarError::InvalidROutput("Cannot find R version"))? } fn get_r_version(