Skip to content

Commit b9c7c0f

Browse files
committed
Fix rig add on Linux and Windows
They have different version names.
1 parent 00f1295 commit b9c7c0f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/common.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,24 @@ pub fn sc_get_list_details() -> Result<Vec<InstalledVersion>, Box<dyn Error>> {
109109

110110
// TODO: we should not hardcode this here...
111111
pub fn check_has_pak(ver: &String) -> Result<bool, Box<dyn Error>> {
112-
let ver = Regex::new("-.*$")?.replace(ver, "").to_string();
113-
let ver = ver + ".0";
112+
// cur off -arm64 and -x86_64
113+
let mut ver = Regex::new("-.*$")?.replace(ver, "").to_string();
114+
115+
// add .0 for macOS minor versions
116+
let minor = Regex::new("^[0-9]+[.][0-9]+$")?;
117+
if minor.is_match(&ver) {
118+
ver = ver + ".0";
119+
}
120+
121+
// cut off extra stuff on Windows
122+
ver = Regex::new("[a-zA-Z][a-zA-Z0-9]*$")?.replace(&ver, "").to_string();
123+
124+
let vv = match Version::parse(&ver) {
125+
Ok(x) => x,
126+
Err(_) => return Ok(true) // devel or next, probably
127+
};
128+
114129
let v350 = Version::parse("3.5.0")?;
115-
let vv = Version::parse(&ver)?;
116130
if vv < v350 {
117131
bail!("Pak is only available for R 3.5.0 or later");
118132
}

tests/test-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ teardown() {
9595

9696
@test "rm" {
9797
if ! rig ls | grep -q '^[* ] 3.3.3$'; then
98-
run rig add 3.3
98+
run rig add 3.3 --without-pak
9999
[[ "$status" -eq 0 ]]
100100
run rig ls
101101
echo "$output" | grep -q "^[* ] 3[.]3[.]3"

0 commit comments

Comments
 (0)