Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/core/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export async function which(cmd: string) {
{ cmd: args, stderr: "piped", stdout: "piped" },
);
if (result.code === 0) {
return result.stdout?.trim();
return Deno.build.os === "windows"
// WHERE return all files found, only first is kept
? result.stdout?.split("\n")[0].trim()
: result.stdout?.trim();
} else {
return undefined;
}
Expand Down
10 changes: 8 additions & 2 deletions src/core/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { existsSync, walkSync } from "fs/mod.ts";
import { dirname, join } from "path/mod.ts";
import { warnOnce } from "./log.ts";
import { which } from "./path.ts";
import { safeExistsSync, which } from "./path.ts";
import { quartoConfig } from "./quarto.ts";
import {
kHKeyCurrentUser,
Expand Down Expand Up @@ -63,7 +63,13 @@ export async function rBinaryPath(binary: string): Promise<string> {
// if there is an R_HOME then respect that
const rHome = Deno.env.get("R_HOME");
if (rHome) {
return join(rHome, "bin", binary);
let rHomeBin = join(rHome, "bin", binary);
if (safeExistsSync(rHomeBin)) return rHomeBin;
if (Deno.build.os === "windows") {
// Some installation have binaries in the sub folder only
rHomeBin = join(rHome, "bin", "x64", binary);
if (safeExistsSync(rHomeBin)) return rHomeBin;
}
}

// then check the path
Expand Down