From 0934cb330b5f595e8214ce49cfb60a8ea54b5037 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 29 Oct 2026 17:21:24 -0700 Subject: [PATCH 1/2] setup.sh: tidy some shell-fu in order to detect flutter and resolve dart better --- tool/ci/setup.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tool/ci/setup.sh b/tool/ci/setup.sh index fb0149e156f..8ae55422167 100755 --- a/tool/ci/setup.sh +++ b/tool/ci/setup.sh @@ -10,25 +10,16 @@ set -ex export SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) export DEVTOOLS_DIR=$SCRIPT_DIR/../.. -# In GitBash on Windows, we have to call flutter.bat so we alias them in this -# script to call the correct one based on the OS. -function flutter { - if [[ $RUNNER_OS == "Windows" ]]; then - command flutter.bat "$@" - else - command flutter "$@" - fi -} -export -f flutter - # Determine the Flutter SDK to use: # * If `DEVTOOLS_TOOL_FLUTTER_FROM_PATH` is "true", then discover from `PATH`. # * If `./tool/flutter-sdk` (a directory) exists, then use that. if [ "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" = "true" ]; then - if command -v flutter &> /dev/null; then - FLUTTER_EXE="$(command -v flutter)" - elif command -v flutter.bat &> /dev/null; then - FLUTTER_EXE="$(command -v flutter.bat)" + # Use `type -P` instead of `command -v` so we resolve an executable file on + # PATH rather than a shell function or alias. + if type -P flutter &> /dev/null; then + FLUTTER_EXE="$(type -P flutter)" + elif type -P flutter.bat &> /dev/null; then + FLUTTER_EXE="$(type -P flutter.bat)" else echo "DEVTOOLS_TOOL_FLUTTER_FROM_PATH is set to true, but flutter was not found on PATH" exit 1 @@ -50,6 +41,17 @@ fi # inopportune times. export PATH="$FLUTTER_DIR/bin/cache/dart-sdk/bin:$FLUTTER_DIR/bin:`pwd`/bin:$PATH" +# In GitBash on Windows, we have to call flutter.bat so we alias them in this +# script to call the correct one based on the OS. +function flutter { + if [[ $RUNNER_OS == "Windows" ]]; then + command flutter.bat "$@" + else + command flutter "$@" + fi +} +export -f flutter + # Look up the latest flutter candidate (this is the latest flutter version in g3) # TODO(https://github.com/flutter/devtools/issues/4591): re-write this script as a # shell script so we won't have to incurr the cost of building flutter tool twice. From 23ca2e04ca52cb350f938390152546e159dbcfb4 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 29 Oct 2026 17:37:47 -0700 Subject: [PATCH 2/2] Update tool/ci/setup.sh Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- tool/ci/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/ci/setup.sh b/tool/ci/setup.sh index 8ae55422167..fab26a724e7 100755 --- a/tool/ci/setup.sh +++ b/tool/ci/setup.sh @@ -44,7 +44,7 @@ export PATH="$FLUTTER_DIR/bin/cache/dart-sdk/bin:$FLUTTER_DIR/bin:`pwd`/bin:$PAT # In GitBash on Windows, we have to call flutter.bat so we alias them in this # script to call the correct one based on the OS. function flutter { - if [[ $RUNNER_OS == "Windows" ]]; then + if [[ "$RUNNER_OS" == "Windows" || "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then command flutter.bat "$@" else command flutter "$@"