Skip to content

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

Description

@davkats

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions