From ba251605e0bc54d21fd6eb51ac860675ea155c31 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 27 Aug 2025 09:09:44 +0200 Subject: [PATCH 1/2] Detect quoted path from ninja on Windows --- server/src/incrementalCompilation.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index cb6a65a04..d9226b6bf 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -7,6 +7,7 @@ import { performance } from "perf_hooks"; import * as p from "vscode-languageserver-protocol"; import * as cp from "node:child_process"; import semver from "semver"; +import * as os from "os"; import config, { send } from "./config"; import * as c from "./constants"; import { fileCodeActions } from "./codeActions"; @@ -555,6 +556,9 @@ function verifyTriggerToken(filePath: string, triggerToken: number): boolean { triggerToken ); } + +const isWindows = os.platform() === "win32"; + async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) { const project = projectsFiles.get(entry.project.rootPath); if (project?.rescriptVersion == null) { @@ -591,10 +595,23 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) { buildArgs.forEach(([key, value]: Array) => { if (key === "-I") { if (isBsb) { - callArgs.push( - "-I", - path.resolve(entry.project.rootPath, c.compilerDirPartialPath, value), - ); + /*build.ninja could have quoted paths on Windows + Example: +rule mij + command = "C:\Users\moi\Projects\my-project\node_modules\rescript\win32\bsc.exe" -I src -I "C:\Users\moi\Projects\my-project\node_modules\@rescript\core\lib\ocaml" -open RescriptCore -uncurried -bs-package-name rewindow -bs-package-output esmodule:$in_d:.res.mjs -bs-v $g_finger $i + */ + if (isWindows && value.startsWith('"') && value.endsWith('"')) { + callArgs.push("-I", value.substring(1, value.length - 1)); + } else { + callArgs.push( + "-I", + path.resolve( + entry.project.rootPath, + c.compilerDirPartialPath, + value, + ), + ); + } } else { // TODO: once ReScript v12 is out we can remove this check for `.` if (value === ".") { From 88e485148ab66d4f6deb687dcd839169b5948890 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 27 Aug 2025 09:41:51 +0200 Subject: [PATCH 2/2] Changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9ab3c56..d82622929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :bug: Bug fix - Protect against trying to read non-existant `.compiler.log`. https://github.com/rescript-lang/rescript-vscode/pull/1116 +- Detected quoted paths in bsb arguments on Windows. https://github.com/rescript-lang/rescript-vscode/pull/1120 #### :rocket: New Feature