Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version finding on multiple lines #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ fn probe_r_paths() -> io::Result<InstallationPaths> {
// 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.
Expand Down Expand Up @@ -294,13 +291,12 @@ fn get_r_version_from_r(r_paths: &InstallationPaths) -> Result<RVersionInfo, Env
.map_err(EnvVarError::RInvocationError)?;

let out = out.as_os_str().to_string_lossy().into_owned();
let mut lines = out.lines();

// Process the first line of the output
match lines.next() {
Some(v) => 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(
Expand Down
Loading