flutter --version
Flutter 3.41.7 • channel stable
Dart 3.11.5
native_toolchain_c version: 0.17.6
Description
Building a Flutter Windows app fails when Visual Studio Build Tools is installed
in the default path (C:\Program Files (x86)...) because native_toolchain_c
passes environment variables like DevEnvDir inline in the shell command without
quoting their values. Windows cmd.exe splits on the space in "Program Files"
and tries to execute "C:\Program" as a command.
Error
Der Befehl "C:\Program" ist entweder falsch geschrieben oder konnte nicht
gefunden werden.
(Translation: The command "C:\Program" is either misspelled or could not be found.)
Cause
In run_cbuilder.dart the developer command prompt environment variables
(DevEnvDir, INCLUDE, LIB, etc.) are passed unquoted, e.g.:
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio...
which causes cmd.exe to interpret "C:\Program" as the executable.
Workaround
Reinstall Visual Studio Build Tools to a path without spaces (e.g. C:\BuildTools).
flutter --version
Flutter 3.41.7 • channel stable
Dart 3.11.5
native_toolchain_c version: 0.17.6
Description
Building a Flutter Windows app fails when Visual Studio Build Tools is installed
in the default path (C:\Program Files (x86)...) because native_toolchain_c
passes environment variables like DevEnvDir inline in the shell command without
quoting their values. Windows cmd.exe splits on the space in "Program Files"
and tries to execute "C:\Program" as a command.
Error
Der Befehl "C:\Program" ist entweder falsch geschrieben oder konnte nicht
gefunden werden.
(Translation: The command "C:\Program" is either misspelled or could not be found.)
Cause
In run_cbuilder.dart the developer command prompt environment variables
(DevEnvDir, INCLUDE, LIB, etc.) are passed unquoted, e.g.:
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio...
which causes cmd.exe to interpret "C:\Program" as the executable.
Workaround
Reinstall Visual Studio Build Tools to a path without spaces (e.g. C:\BuildTools).