[flutter_tools] exit with helpful message if where is missing on windows (#65112)

This commit is contained in:
Jonah Williams
2020-09-02 16:50:04 -07:00
committed by GitHub
parent 68c1b441be
commit d3fd62c843
2 changed files with 21 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import 'package:meta/meta.dart';
import 'package:process/process.dart';
import '../globals.dart' as globals;
import 'common.dart';
import 'file_system.dart';
import 'io.dart';
import 'logger.dart';
@@ -289,7 +290,18 @@ class _WindowsUtils extends OperatingSystemUtils {
@override
List<File> _which(String execName, { bool all = false }) {
// `where` always returns all matches, not just the first one.
final ProcessResult result = _processManager.runSync(<String>['where', execName]);
ProcessResult result;
try {
result = _processManager.runSync(<String>['where', execName]);
} on ArgumentError {
// `where` could be missing if system32 is not on the PATH.
throwToolExit(
'Cannot find the executable for `where`. This can happen if the System32 '
'folder (e.g. C:\\Windows\\System32 ) is removed from the PATH environment '
'variable. Ensure that this is present and then try again after restarting '
'the terminal and/or IDE.'
);
}
if (result.exitCode != 0) {
return const <File>[];
}