From 2d558ccb7151d62251b0db2d8baff74655439094 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 7 Nov 2023 14:31:30 +0000 Subject: [PATCH] Fix an issue locating the Flutter SDK on Windows when not invoked via 'dart' inside a Flutter SDK (#6668) If the current Dart VM isn't inside a Flutter SDK, we fall back to trying to find it on `PATH` with `which`. The equiv on Windows is `where.exe`. --- tool/lib/model.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/lib/model.dart b/tool/lib/model.dart index ed99ab836f8..634301030e6 100644 --- a/tool/lib/model.dart +++ b/tool/lib/model.dart @@ -128,8 +128,8 @@ class FlutterSdk { } // Look to see if we can find the 'flutter' command in the PATH. - // TODO(dantup): This won't work on Windows. - final result = Process.runSync('which', ['flutter']); + final whichCommand = Platform.isWindows ? 'where.exe' : 'which'; + final result = Process.runSync(whichCommand, ['flutter']); if (result.exitCode == 0) { final sdkPath = result.stdout.toString().split('\n').first.trim(); // 'flutter/bin'