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.
Summary
Starting a build from the language server fails on Windows because the path returned by
findRescriptBinary()no longer matches whatrunBuildWatcherUsingValidBuildPath()expects.The build watcher exits immediately with:
As a result, features that depend on the build watcher (such as fresh type information) do not work until a separate
rescript watchprocess is started manually.Environment
Investigation
In extension version 1.50.0,
findRescriptBinary()searched for:runBuildWatcherUsingValidBuildPath()then executed:which correctly resolved to:
The current implementation of
findRescriptBinary()returns the package wrapper instead.For ReScript 12:
For older ReScript versions (10, 11):
However,
runBuildWatcherUsingValidBuildPath()still appends.cmd:or
Neither of these files exists.
The actual Windows launcher generated by npm is still:
Logs
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 returnnode_modules/.bin/rescriptmay not be the best approach.Instead,
runBuildWatcherUsingValidBuildPath()could resolve the appropriate Windows launcher from the returned path before callingexec(), preserving the current responsibilities offindRescriptBinary()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 watchmanually works correctly. My investigation points to the Windows launcher path being constructed from a different kind of path than the code expects.