From b2ecaa92f9da88215fdd2c044f6f8b34f2dbe35b Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Tue, 3 Feb 2026 09:23:14 -0500 Subject: [PATCH] [ CI ] Don't crash analysis when ktlint isn't on PATH Fixes https://github.com/flutter/flutter/issues/181284 --- dev/bots/analyze.dart | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 0c6a5dd4db9..390158708eb 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -2237,6 +2237,8 @@ Stream _allFiles( class EvalResult { EvalResult({required this.stdout, required this.stderr, this.exitCode = 0}); + static const kNotFoundExitCode = 127; + final String stdout; final String stderr; final int exitCode; @@ -2260,12 +2262,18 @@ Future _evalCommand( } final time = Stopwatch()..start(); - final Process process = await Process.start( - executable, - arguments, - workingDirectory: workingDirectory, - environment: environment, - ); + final Process process; + + try { + process = await Process.start( + executable, + arguments, + workingDirectory: workingDirectory, + environment: environment, + ); + } on ProcessException catch (e) { + return EvalResult(stdout: '', stderr: e.toString(), exitCode: EvalResult.kNotFoundExitCode); + } final Future>> savedStdout = process.stdout.toList(); final Future>> savedStderr = process.stderr.toList(); @@ -2532,7 +2540,9 @@ Future lintKotlinFiles(String workingDirectory) async { '--baseline=$flutterRoot/$baselineRelativePath', '--editorconfig=$flutterRoot/$editorConfigRelativePath', ], workingDirectory: workingDirectory); - if (lintResult.exitCode != 0) { + if (lintResult.exitCode == EvalResult.kNotFoundExitCode) { + foundError(['Failed to find ktlint on PATH. Kotlin code analysis failed.']); + } else if (lintResult.exitCode != 0) { final errorMessage = 'Found lint violations in Kotlin files:\n ${lintResult.stdout}\n\n' 'To reproduce this lint locally:\n'