-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
The issue is breaking every user that is using localizations and a custom FLUTTER_STORAGE_BASE_URL.
This also happens with flutter pub get if the l10n generation is synthetic.
The tool will report Found syntax errors but not any actual syntax errors.
Related issues:
- When run flutter gallery loaclly, faced with exception with Syntax Error when try to pub get. #117610
flutter gen-i10nthrowsFound syntax errors.after upgrading to 3.7.0 (mostly affecting china mirror) #119435- Flutter 3.7.0 Cause Localization Bug #119585
Root cause
When FLUTTER_STORAGE_BASE_URL is being overridden, the cache getter will try to raise an error to STDERR that the user is using a custom storage base.
flutter/packages/flutter_tools/lib/src/cache.dart
Lines 523 to 526 in 5b6572f
| _logger.printError( | |
| 'Flutter assets will be downloaded from $overrideUrl. Make sure you trust this source!', | |
| emphasis: true, | |
| ); |
But using an error print will cause the generate tool recognized as an exception.
flutter/packages/flutter_tools/lib/src/localizations/gen_l10n.dart
Lines 1249 to 1252 in 5b6572f
| // If there were any syntax errors, don't write to files. | |
| if (logger.hadErrorOutput) { | |
| throw L10nException('Found syntax errors.'); | |
| } |
And when it's using synthetic package, flutter pub get will also raise exceptions.
flutter/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart
Lines 61 to 67 in 5b6572f
| if (result.hasException) { | |
| throwToolExit( | |
| 'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:' | |
| '\n\n' | |
| '${result.exceptions.values.map<Object?>((ExceptionMeasurement e) => e.exception).join('\n\n')}', | |
| ); | |
| } |
Steps to Reproduce
- Run
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cnin the terminal. flutter create test_l10n- Setup internationalization for the project according to the doc.
flutter pub getorflutter gen-l10n
flutter doctor -v
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[!] Flutter (Channel stable, 3.7.0, on Microsoft Windows [版本 10.0.22000.1455], locale zh-CN)
• Flutter version 3.7.0 on channel stable at X:\SDK\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (7 days ago), 2023-01-23 16:55:55 -0800
• Engine revision b24591ed32
• Dart version 2.19.0
• DevTools version 2.20.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
