Skip to content

[gen-l10n] Failed to complete the generation when FLUTTER_STORAGE_BASE_URL is overridden #119593

Description

@AlexV525

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.

C 2GWA62)A7VKK 59JJ3%31

The tool will report Found syntax errors but not any actual syntax errors.

Related issues:

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.

_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.

// 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.

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

  1. Run export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn in the terminal.
  2. flutter create test_l10n
  3. Setup internationalization for the project according to the doc.
  4. flutter pub get or flutter 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

Activity

  1. added
    c: regressionIt was better in the past than it is now
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    on Jan 31, 2023
  2. AlexV525 commented on Jan 31, 2023

    @AlexV525
    MemberAuthor

    cc @thkim1011 I'm going to submit a quick fix to use a warning instead of an error for the storage override.

  3. AlexV525 commented on Jan 31, 2023

    @AlexV525
    MemberAuthor

    Workaround steps:

    1. Change the below line to printWarning.
    2. Delete flutter_tools.snapshot and flutter_tools.stamp under the ${path_to_flutter_sdk}/bin/cache.
    3. Rerun any Flutter commands.
  4. darshankawar commented on Jan 31, 2023

    @darshankawar
    Member

    Similar issue: #119435

  5. conghaonet commented on Jan 31, 2023

    @conghaonet

    Workaround steps:

    1. Change the below line to printWarning.
    2. Delete flutter_tools.snapshot and flutter_tools.stamp under the ${path_to_flutter_sdk}/bin/cache.
    3. Rerun any Flutter commands.

    It is worked!

  6. changed the title [-][gen-l10n] Failed to complete the generation is `FLUTTER_STORAGE_BASE_URL` is overridden[/-] [+][gen-l10n] Failed to complete the generation when `FLUTTER_STORAGE_BASE_URL` is overridden[/+] on Jan 31, 2023
  7. self-assigned this
    on Jan 31, 2023
  8. thkim1011 commented on Jan 31, 2023

    @thkim1011
    Contributor

    Working on a fix right now.

  9. christopherfujino commented on Feb 1, 2023

    @christopherfujino
    Contributor

    @thkim1011 thanks so much for the quick fix! Could you also request a cherrypick to the stable channel via the issue template?

  10. AlexV525 commented on Feb 2, 2023

    @AlexV525
    MemberAuthor

    @thkim1011 thanks so much for the quick fix! Could you also request a cherrypick to the stable channel via the issue template?

    #119678

  11. christopherfujino commented on Feb 2, 2023

    @christopherfujino
    Contributor

    @thkim1011 thanks so much for the quick fix! Could you also request a cherrypick to the stable channel via the issue template?

    #119678

    Thanks!

  12. github-actions commented on Mar 3, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Mar 3, 2023
  14. added
    P0Critical issues such as a build break or regression
    and removed on Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: internationalizationSupporting other languages or locales. (aka i18n)c: regressionIt was better in the past than it is nowtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions