rescript-lang / rescript-lang/rescript-vscode

Windows: Start Build uses an invalid .cmd path after findBinary refactor

Open
#1,186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
ReScript
Stars
354
Forks
63
Avg merge
11h 29m
Merged PRs (30d)
1

Description

Summary

Starting a build from the language server fails on Windows because the path returned by findRescriptBinary() no longer matches what runBuildWatcherUsingValidBuildPath() expects.

The build watcher exits immediately with:

Build watcher exited with code 1, signal null

As a result, features that depend on the build watcher (such as fresh type information) do not work until a separate rescript watch process is started manually.

Environment

  • OS: Windows 10
  • Extension: 1.73.11
  • ReScript: 12.3.0 (also reproduced on 12.0.0)

Investigation

In extension version 1.50.0, findRescriptBinary() searched for:

node_modules/.bin/rescript

runBuildWatcherUsingValidBuildPath() then executed:

childProcess.exec(`"${buildPath}".cmd ...`)

which correctly resolved to:

node_modules/.bin/rescript.cmd

The current implementation of findRescriptBinary() returns the package wrapper instead.

For ReScript 12:

node_modules/rescript/cli/rescript.js

For older ReScript versions (10, 11):

node_modules/rescript/rescript

However, runBuildWatcherUsingValidBuildPath() still appends .cmd:

".../node_modules/rescript/cli/rescript.js".cmd

or

".../node_modules/rescript/rescript".cmd

Neither of these files exists.

The actual Windows launcher generated by npm is still:

node_modules/.bin/rescript.cmd

Logs

Starting build watcher for ... (ReScript 12.3.0)
Running build watcher: ...\node_modules\rescript\cli\rescript.js watch
Build watcher exited with code 1, signal null

Possible fix

Since findRescriptBinary() is now also used for purposes other than starting the build watcher (for example, monorepo-related logic), changing it back to return node_modules/.bin/rescript may not be the best approach.

Instead, runBuildWatcherUsingValidBuildPath() could resolve the appropriate Windows launcher from the returned path before calling exec(), preserving the current responsibilities of findRescriptBinary() while restoring the expected Windows behavior.

Related

This appears to be related to issue #1181.

That issue reports that Start Build exits immediately while running rescript watch manually works correctly. My investigation points to the Windows launcher path being constructed from a different kind of path than the code expects.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading findRescriptBinary() and runBuildWatcherUsingValidBuildPath(), then trace how the returned ReScript path is passed to childProcess.exec on Windows. Verify that the watcher resolves the existing node_modules/.bin/rescript.cmd launcher without breaking the other uses of findRescriptBinary(), and confirm that Start Build no longer exits immediately.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.