Skip to content

Commit 44b37f0

Browse files
authored
Merge pull request #1051 from quarto-dev/fix-find-r-windows
[Windows] Improve R finding for special installation
2 parents abb46a3 + 964620d commit 44b37f0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/core/path.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export async function which(cmd: string) {
9595
{ cmd: args, stderr: "piped", stdout: "piped" },
9696
);
9797
if (result.code === 0) {
98-
return result.stdout?.trim();
98+
return Deno.build.os === "windows"
99+
// WHERE return all files found, only first is kept
100+
? result.stdout?.split("\n")[0].trim()
101+
: result.stdout?.trim();
99102
} else {
100103
return undefined;
101104
}

src/core/resources.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { existsSync, walkSync } from "fs/mod.ts";
99
import { dirname, join } from "path/mod.ts";
1010
import { warnOnce } from "./log.ts";
11-
import { which } from "./path.ts";
11+
import { safeExistsSync, which } from "./path.ts";
1212
import { quartoConfig } from "./quarto.ts";
1313
import {
1414
kHKeyCurrentUser,
@@ -63,7 +63,13 @@ export async function rBinaryPath(binary: string): Promise<string> {
6363
// if there is an R_HOME then respect that
6464
const rHome = Deno.env.get("R_HOME");
6565
if (rHome) {
66-
return join(rHome, "bin", binary);
66+
let rHomeBin = join(rHome, "bin", binary);
67+
if (safeExistsSync(rHomeBin)) return rHomeBin;
68+
if (Deno.build.os === "windows") {
69+
// Some installation have binaries in the sub folder only
70+
rHomeBin = join(rHome, "bin", "x64", binary);
71+
if (safeExistsSync(rHomeBin)) return rHomeBin;
72+
}
6773
}
6874

6975
// then check the path

0 commit comments

Comments
 (0)