Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Binary resolution fails on Windows with ERR_INVALID_URL_SCHEME when compiler-info.json is missing

未关闭 适合新手
#1,184 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
node.js, typescript
领域
devtools

调研方向

首先定位在缺少 compiler-info.json 时导入 targetPackagePath 的备用二进制解析代码,并检查 PR #1177 中的更改。使用报告的 Node 版本重现 Windows 失败问题,并验证备用逻辑无需 compiler-info.json 即可成功解析二进制文件;参考 #1181 了解相关的路径处理背景。

由索引模型根据 Issue 内容生成。

描述

Environment

  • OS: Windows 10 x64
  • VS Code extension: v1.73.11 (Pre-release)
  • Language Server: v1.72.0
  • ReScript: 12.3.0
  • Node: tested with 20.20.2, 22.23.1, and 24.18.0

Problem

When compiler-info.json is missing, the language server falls back to resolving binaries through:

await import(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.
await import(path)

Result on Node 20, 22 and 24:

ERR_UNSUPPORTED_ESM_URL_SCHEME
2. (current implementation)
await import(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.
await import(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().

Replacing

await import(fileURLToPath(targetPackagePath))

with

await import(pathToFileURL(targetPackagePath).href)

resolved the issue in all of my Windows tests.

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.

主要语言
ReScript
星标
356
派生
63
平均合并
11 小时 29 分钟
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rescript-lang/rescript-vscode 的其他 Issue

查看 rescript-lang/rescript-vscode 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。