Open mit-mit opened 2 years ago
Hi @mit-mit, Thanks for filing the issue. I am able to reproduce the issue with the newly downloaded sdk.
mahesh@Maheshs-MacBook-Air-M1 ~ % ~/Downloads/flutter/bin/flutter --version
VersionCheckError: Command exited with code 128: git fetch
__flutter_version_check__ stable
Standard error: fatal: unable to access
'https://github.com/flutter/flutter.git/': Could not resolve host: github.com
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (4 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
mahesh@Maheshs-MacBook-Air-M1 ~ %
So technically, the command did not fail, as it still printed out the version:
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (3 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
This error is actually not coming from the --version
code, but actually the tool will periodically check if there is a newer version available upstream. Any time it does this check but the git fetch
fails, we print the git error message to stderr as a warning, in case their git repo is misconfigured.
OK, let me rephrase: "seems like it fails when offline". The output is very confusing and error like. Can we at least trim it down a bit and make it look less like some random error was thrown? E.g.:
$ ~/tmp/flutter/bin/flutter --version
Warning: Flutter version check failed. Could not resolve host: github.com
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (3 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
Even better, could the flutter
tool do an actual check for offline? I suspect we could create a small plugin that calls into OS apis for this (e.g. SCNetworkReachability
on macOS)?
Repro steps
Download a stable macOS build from the releases page: https://docs.flutter.dev/development/tools/sdk/releases
Go offline (turn off wifi and anyther other network connection)
Extract the downloaded zip (e.g. ~/tmp/flutter)
Open a terminal, and run
~/tmp/flutter/bin/flutter --version
Actual result
Expected result|
No error.