Skip to content

Commit 53de302

Browse files
committed
Win: inject rtools path on R 4.0/4.1 as well
1 parent cfc97ef commit 53de302

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/windows/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,12 @@ fn rtools_renviron_lines(version: &str, arch: &str, rtools_path: &Path, user_mod
539539
path, path
540540
)
541541
} else if version == "40" {
542-
// Rtools 4.0: R does not auto-derive PATH, so keep the explicit PATH line that
543-
// references RTOOLS40_HOME (set here in user mode, by the installer in admin mode).
544542
let var = rtools_home_var(version, arch);
545543
let mut s = String::new();
546544
if user_mode {
547545
s += &format!("{}=\"{}\"\n", var, path);
546+
} else {
547+
s += &format!("{var}=\"${{{var}:-{path}}}\"\n", var = var, path = path);
548548
}
549549
s += &format!(
550550
"PATH=\"${{{var}}}/ucrt64/bin;${{{var}}}/usr/bin;${{PATH}}\"",
@@ -2410,9 +2410,8 @@ mod tests {
24102410
let l40 = rtools_renviron_lines("40", "x86_64", Path::new("C:\\rt\\Rtools40"), true);
24112411
assert!(l40.starts_with("RTOOLS40_HOME=\"C:/rt/Rtools40\"\n"));
24122412
assert!(l40.contains("${RTOOLS40_HOME}/ucrt64/bin"));
2413-
// 4.0 in admin mode keeps only the PATH line (installer sets the var).
24142413
let l40a = rtools_renviron_lines("40", "x86_64", Path::new("C:\\Rtools40"), false);
2415-
assert!(!l40a.contains("RTOOLS40_HOME=\""));
2414+
assert!(l40a.starts_with("RTOOLS40_HOME=\"${RTOOLS40_HOME:-C:/Rtools40}\"\n"));
24162415
assert!(l40a.contains("${RTOOLS40_HOME}/usr/bin"));
24172416
// 3.5 prepends <path>/bin to PATH.
24182417
assert_eq!(

0 commit comments

Comments
 (0)