dt run on Windows crashes horribly with ProcessException: The system cannot find the file specified
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- dart
- Ambito
- cli, devtools, operating-systems
Direzione di ricerca
Inizia da tool/lib/commands/serve.dart intorno alla riga 247 e riproduci dt run su Windows dopo aver seguito la configurazione documentata di Dart SDK. Traccia come viene avviato il comando gclient sync e confronta questo comportamento con i requisiti dei file batch di Windows; il lavoro è completato quando dt run può avviare il server e il frontend senza ProcessException, con la configurazione richiesta documentata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
After setting up devtools on Windows properly, running dt run in the root directory to start the devtools server and frontend fails horribly with the following:
[serve] running gclient sync in the local dart sdk
C:\Users\User\Downloads\VSCode\dart-lang\sdk > gclient sync
ProcessException: The system cannot find the file specified (at ../../runtime/bin/process_win.cc:577)
Command: gclient sync
#0 _ProcessImpl._start (dart:io-patch/process_patch.dart:411:33)
#1 Process.start (dart:io-patch/process_patch.dart:42:20)
#2 ProcessManager.spawn (package:io/src/process_manager.dart:78:32)
#3 DevToolsProcessManagerExtension.runProcess (package:devtools_tool/utils.dart:143:27)
#4 ServeCommand.run (package:devtools_tool/commands/serve.dart:246:26)
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:27)
#6 DevToolsCommandRunner.runCommand (package:devtools_tool/devtools_command_runner.dart:92:18)
#7 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:122:25)
#8 new Future.sync (dart:async/future.dart:325:27)
#9 CommandRunner.run (package:args/command_runner.dart:122:14)
#10 main (file:///C:/Users/User/Downloads/VSCode/devtools/tool/bin/dt.dart:15:10)
#11 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:312:33)
#12 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)
ProcessException: Failed with exit code: 1.
Command: C:\Users\User\Downloads\VSCode\devtools\tool\flutter-sdk\bin\dart.bat C:\Users\User\Downloads\VSCode\devtools\tool\bin\dt.dart serve --run-app
#0 DevToolsProcessManagerExtension.runProcess (package:devtools_tool/utils.dart:152:7)
<asynchronous suspension>
#1 RunCommand.run (package:devtools_tool/commands/run.dart:34:21)
<asynchronous suspension>
#2 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#3 SharedStdIn.terminate (package:io/src/shared_stdin.dart:91:3)
<asynchronous suspension>
#4 main (file:///C:/Users/User/Downloads/VSCode/devtools/tool/bin/dt.dart:14:28)
<asynchronous suspension>
I debugged this for quite a while and it appears that the code at https://github.com/flutter/devtools/blob/cac09a934e33e7e4b18cf3af5d4c9514fafd2077/tool/lib/commands/serve.dart#L247 attempts to run gclient sync as a process, which is ultimately implemented as a CreateProcessW call in the deepest darkest parts of the Dart VM. It's important to note that in this case, the gclient executable we are trying to run is a batch file (As depot_tools does not support running the gclient executable in anything but cmd on Windows, meaning the shell script version can be disregarded, although even if it was supported, there would be no difference, as is later explained). However, the Windows documentation states
To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.
The reason for this becomes apparent once you realize that CreateProcessW, regardless of the several different ways you can call it, only ever expects exe files when no file extension is given. So when that runProcess call is executed during dt run, what Windows is actually looking for is a gclient.exe, not gclient.bat as is actually intended. This in turn ends up making the attempt to run the gclient process explode. Tracking the CreateProcessW call from the Dart VM confirms this, as the paths shown are all variants of C:\Users\User\Downloads\VSCode\depot_tools\gclient.exe or C:\Users\User\Downloads\VSCode\depot_tools\gclient sync.exe for every entry in PATH, since Windows is trying and failing to find gclient.exe in each directory listed in PATH (The latter is because Windows is desperately trying to find an executable to make the user code happy, and in its desperation, since the application name parameter is not specified to CreateProcessW by the Dart VM, it interprets the entire gclient sync command as the executable name itself)
I don't know how best to fix this. The optimal fix would be to run cmd.exe /c gclient.bat as the CreateProcessW documentation suggests, but the Dart VM does not expose any way for the first parameter of the CreateProcessW call to be set from Dart, instead hardcoding it to nullptr while it uses the second process arguments parameter as the name of the process itself. Maybe a hack could be put in place for Windows in the devtools, given that a full fix requires rearchitecting the Dart VM's process code and the API it exposes quite a bit.
One other thing I also noticed is that the documention for devtools for running both server and frontend implies that simply cloning the Dart SDK is enough, but the actual code suggests something very different, namely that you seem to need depot_tools, particularly gclient, as well as having cloned Dart using fetch from depot_tools rather than just regular git clone.
- Lingua principale
- Dart
- Stelle
- 1.7k
- Fork
- 405
- Merge medio
- 4g 23h
- PR unite (30g)
- 12
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di flutter/devtools
-
cleanup P1
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
a: quality cost: low P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
contributions welcome good first issue P2 screen: performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
contributions welcome cross-screen inspector-2.0-polish P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
cross-screen P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tutte le issue di flutter/devtools
Issue simili
-
improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
linagora/tmail-flutter#4849 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
mlcommons/mobile_app_open#1182 ·
-
[Bug] Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bggRGjQaUbCoE/PiliPlus#3048 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
zulip/zulip-flutter#2466 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100