dt run on Windows crashes horribly with ProcessException: The system cannot find the file specified
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- dart
- Área
- cli, devtools, operating-systems
Línea de trabajo
Comienza con tool/lib/commands/serve.dart alrededor de la línea 247 y reproduce dt run en Windows después de seguir la configuración documentada de Dart SDK. Rastrea cómo se inicia el comando gclient sync y compara ese comportamiento con los requisitos de los archivos por lotes de Windows; se considera terminado cuando dt run puede iniciar el servidor y el frontend sin ProcessException, con la configuración requerida documentada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Dart
- Estrellas
- 1.7k
- Forks
- 405
- Merge medio
- 4 d 21 h
- PR fusionados (30 d)
- 15
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de flutter/devtools
-
cleanup P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
`dcm analyze` false positives Abiertoa: quality cost: low P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
contributions welcome cross-screen inspector-2.0-polish P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Support removing storage keys Abiertocross-screen P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
documentation good first issue P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Todos los issues de flutter/devtools
Issues similares
-
status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
a2ui-project/a2ui#2782 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
MaikuB/flutter_local_notifications#2832 · 1 comentario ·
-
[Bug]: New version of nm package Abiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
fluttercommunity/plus_plugins#3979 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
from.page-issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100