Binary resolution fails on Windows with ERR_INVALID_URL_SCHEME when compiler-info.json is missing
まだ誰も着手していません。
評価
- 難易度
- 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.jsondoes 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分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript-vscode のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rescript-lang/rescript-vscode#1185 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
rescript-lang/rescript-vscode#1192 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
rescript-lang/rescript-vscode#1186 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
rescript-lang/rescript-vscode#1182 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rescript-lang/rescript-vscode#1175 ·
rescript-lang/rescript-vscode の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 3 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
implement-spec: step 9 cleanup collides with branch -D guards and with rewritten integration historyオープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mattpocock/skills#1251 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信