You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Binary resolution fails on Windows with ERR_INVALID_URL_SCHEME when compiler-info.json is missing #1184
When compiler-info.json is missing, the language server falls back to resolving binaries through:
awaitimport(url.fileURLToPath(targetPackagePath))
On Windows this consistently throws:
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
As a result, the language server cannot resolve ReScript binaries through the fallback path.
Investigation
This only happens when:
ReScript version is >= 12.0.0-alpha.13
compiler-info.json does not exist, causing the fallback code path to execute.
If compiler-info.json exists (for example after a successful build), this code path is skipped, making the issue difficult to notice.
I reproduced the problem outside of the extension using a minimal Node script.
For the same filesystem path:
D:\...\node_modules\@rescript\win32-x64\bin.js
I tested all supported approaches.
1.
awaitimport(path)
Result on Node 20, 22 and 24:
ERR_UNSUPPORTED_ESM_URL_SCHEME
2. (current implementation)
awaitimport(fileURLToPath(path))
Result on Node 20, 22 and 24:
ERR_INVALID_URL_SCHEME
This happens because fileURLToPath() expects a file:// URL, but path is already a filesystem path.
3.
awaitimport(pathToFileURL(path).href)
Result:
Works correctly on Node 20, Node 22 and Node 24.
Since the value being imported is already a filesystem path (as the variable name also suggests) and is immediately passed to import(), converting it with pathToFileURL() matches the intended Node.js API for dynamic ESM imports.
Although I only tested this on Windows, this should behave consistently across platforms because pathToFileURL() converts native filesystem paths into valid file:// URLs on both Windows and POSIX systems.
Expected fix
It looks like the fallback should import a file URL, not convert a filesystem path with fileURLToPath().
Since the imported value is already a filesystem path, this should also be the correct cross-platform approach rather than a Windows-specific workaround.
I also noticed that PR #1177 introduced the current fileURLToPath() implementation. Based on my testing, it looks like the original issue (await import(path)) was replaced with another issue caused by calling fileURLToPath() on an existing filesystem path.
This may also be related to #1181 since both issues involve Windows path handling during binary resolution.
changed the title [-]Windows: Binary resolution fails with ERR_INVALID_URL_SCHEME when compiler-info.json is missing[/-][+]Binary resolution fails on Windows with ERR_INVALID_URL_SCHEME when compiler-info.json is missing[/+]on Jul 20, 2026
Activity
[-]Windows: Binary resolution fails with ERR_INVALID_URL_SCHEME when compiler-info.json is missing[/-][+]Binary resolution fails on Windows with ERR_INVALID_URL_SCHEME when compiler-info.json is missing[/+]