Skip to content

Windows build fails when Visual Studio is installed in default path (spaces in Program Files) #3321

@JoshuaR457

Description

@JoshuaR457

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions