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

Aperta
#1,186 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
node.js, typescript

Direzione di ricerca

Inizia leggendo findRescriptBinary() e runBuildWatcherUsingValidBuildPath(), quindi segui il modo in cui il percorso ReScript restituito viene passato a childProcess.exec su Windows. Verifica che il watcher risolva il launcher esistente node_modules/.bin/rescript.cmd senza compromettere gli altri utilizzi di findRescriptBinary(), e conferma che Start Build non termini più immediatamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
ReScript
Stelle
354
Fork
63
Merge medio
11h 29m
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rescript-lang/rescript-vscode

Tutte le issue di rescript-lang/rescript-vscode

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.