CI: locate Flutter on the runner instead of assuming it is on PATH
Some checks failed
CI / Windows build (push) Has been cancelled
Some checks failed
CI / Windows build (push) Has been cancelled
Root cause of the failing Windows runs (seen in the runner logs): the Actions shell does not inherit Flutter on PATH, so `flutter --version` failed in ~30s. Checkout via the gitea.com mirror works fine. Add a "Locate Flutter" step that checks PATH, the FLUTTER_ROOT repo variable, and common Windows install locations, then prepends it via GITHUB_PATH so later steps find flutter. Fails with a clear message if not found. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,36 @@ jobs:
|
|||||||
# git -c http.extraheader="AUTHORIZATION: basic $h" fetch --depth=1 origin "${{ github.sha }}"
|
# git -c http.extraheader="AUTHORIZATION: basic $h" fetch --depth=1 origin "${{ github.sha }}"
|
||||||
# git checkout --force FETCH_HEAD
|
# git checkout --force FETCH_HEAD
|
||||||
|
|
||||||
- name: Flutter version (must be pre-installed on the runner)
|
# The runner's Actions shell often does not inherit Flutter on PATH, so
|
||||||
|
# locate it and add it to PATH for subsequent steps. Override by setting
|
||||||
|
# the repo variable FLUTTER_ROOT (Settings > Actions > Variables) to your
|
||||||
|
# Flutter SDK directory, or just add Flutter's bin to the system PATH.
|
||||||
|
- name: Locate Flutter
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
if (Get-Command flutter -ErrorAction SilentlyContinue) {
|
||||||
|
Write-Host "flutter already on PATH"; exit 0
|
||||||
|
}
|
||||||
|
$candidates = @()
|
||||||
|
if ("${{ vars.FLUTTER_ROOT }}") { $candidates += (Join-Path "${{ vars.FLUTTER_ROOT }}" 'bin') }
|
||||||
|
if ($env:FLUTTER_ROOT) { $candidates += (Join-Path $env:FLUTTER_ROOT 'bin') }
|
||||||
|
$candidates += @(
|
||||||
|
'C:\flutter\bin','C:\src\flutter\bin','C:\tools\flutter\bin','C:\dev\flutter\bin',
|
||||||
|
"$env:USERPROFILE\flutter\bin","$env:USERPROFILE\development\flutter\bin",
|
||||||
|
"$env:LOCALAPPDATA\flutter\bin",'C:\fvm\default\bin'
|
||||||
|
)
|
||||||
|
$found = $null
|
||||||
|
foreach ($c in $candidates) {
|
||||||
|
if ($c -and (Test-Path (Join-Path $c 'flutter.bat'))) { $found = $c; break }
|
||||||
|
}
|
||||||
|
if (-not $found) {
|
||||||
|
Write-Error "Flutter not found on PATH or in common locations. Add Flutter's bin to the runner PATH, or set repo variable FLUTTER_ROOT to your Flutter SDK directory."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Write-Host "Found Flutter at $found"
|
||||||
|
Add-Content -Path $env:GITHUB_PATH -Value $found
|
||||||
|
|
||||||
|
- name: Flutter version
|
||||||
run: flutter --version
|
run: flutter --version
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
Reference in New Issue
Block a user