Skip to content

flutter pub get fails at workspace root when an app package l10n.yaml uses untranslated-messages-file #174205

@EchoEllet

Description

@EchoEllet

Issue

Running flutter pub get from the workspace root fails if any app package has an l10n.yaml with the untranslated-messages-file property set.

Error output of flutter pub get

Generating synthetic localizations package failed with 1 error:

PathNotFoundException: Cannot open file, path = 'l10n/untranslated.json' (OS Error: No such file or directory, errno = 2)

Motivation

Support having a l10n.yaml file in each app package when using pub workspaces (monorepo support).

Therefore, running flutter gen-l10n inside an app package should generate the localization files within that app package; however, running flutter pub get from the workspace root should not fail (this is the issue reported). To generate localization files manually, it is necessary to set flutter.generate to true in the app package's pubspec.yaml, so that flutter gen-l10n does not fail.

Reproducing the issue

Switch to Flutter 3.35.1:

flutter channel stable
flutter upgrade

Option 1: Reproduce Using a Minimal Example Project

The quickest way to reproduce the issue is by cloning this minimal reproducible example:

git clone --depth 1 https://github.com/EchoEllet/flutter_pub_get_l10n_workspace_reproduce.git
cd flutter_pub_get_l10n_workspace_reproduce
flutter pub get

You could also download the minimal project as a zip file if needed.

Option 2: Manual Reproduction via a New Project

Follow these steps to reproduce the issue by creating a new Flutter project:

  1. flutter create flutter_pub_get_l10n_workspace_reproduce --platforms=web --empty

  2. cd flutter_pub_get_l10n_workspace_reproduce

  3. flutter pub add intl:any and flutter pub add flutter_localizations --sdk=flutter

  4. nano l10n.yaml with:

    arb-dir: l10n
    template-arb-file: app_en.arb
    output-localization-file: app_localizations.dart
    untranslated-messages-file: l10n/untranslated.json # IMPORTANT to reproduce the issue
  5. mkdir -p l10n && echo '{}' > l10n/app_en.arb && echo '{}' > l10n/untranslated.json

  6. Set flutter.generate to true in pubspec.yaml

     flutter:
       generate: true # IMPORTANT to reproduce the issue
  7. flutter pub get without any failures. Run flutter clean (IMPORTANT to reproduce) and then mkdir app && mv * app/

  8. nano pubspec.yaml with:

    name: _
    publish_to: none
    environment:
      sdk: ^3.9.0
    workspace:
      - app
  9. (cd app && flutter clean) && flutter clean

  10. flutter pub get (run at the root workspace)

I was able to reproduce the issue in my current Flutter app project and also in a minimal example as shown above.

Workarounds

  • Run flutter pub get inside the app package first (example in a CI workflow).
  • Avoid setting untranslated-messages-file.
  • Running mkdir l10n at the workspace level and then flutter pub get solves the issue. Still, this is likely unexpected, because the l10n.yaml file inside an app package should resolve its paths of untranslated-messages-file relative to that package.
  • Update untranslated-messages-file to set the file path from the root workspace (l10n/untranslated.json -> app/l10n/untranslated.json), but not really a solution, it will cause another issue (Oops; flutter has exited unexpectedly: "PathNotFoundException: Cannot open file, path = 'app/l10n/untranslated.json' (OS Error: No such file or directory, errno = 2)) when running flutter gen-l10n inside the app directory (where l10n.yaml file exists). The arb-dir directory path does not need to be resolved from the root (l10n instead of app/l10n) and works without any issues (also the case for output-dir). This indicates an issue with untranslated-messages-file.
  • Set flutter.generate to false in app/pubspec.yaml, but then flutter gen-l10n will also fail, similar to the previous workaround, but this time with an expected error.

Flutter doctor output

Details

[✓] Flutter (Channel stable, 3.35.1, on macOS 15.5 24F74 darwin-arm64, locale
    en-US) [511ms]
    • Flutter version 3.35.1 on channel stable at
      /Users/ellet/Developer/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 20f8274939 (7 days ago), 2025-08-14 10:53:09 -0700
    • Engine revision 1e9a811bf8
    • Dart version 3.9.0
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-swift-package-manager, enable-lldb-debugging

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
    [1,557ms]
    • Android SDK at /Users/ellet/Library/Android/sdk
    • Emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Users/ellet/Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor
      --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,136ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [27ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [26ms]
    • Android Studio at /Users/ellet/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)

[✓] IntelliJ IDEA Community Edition (version 2025.2) [25ms]
    • IntelliJ at /Users/ellet/Applications/IntelliJ IDEA Community Edition.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.103.1) [7ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (2 available) [6.3s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 139.0.7258.129

[✓] Network resources [619ms]
    • All expected network resources are available

Additional context

Could be useful:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions