-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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 upgradeOption 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 getYou 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:
-
flutter create flutter_pub_get_l10n_workspace_reproduce --platforms=web --empty -
cd flutter_pub_get_l10n_workspace_reproduce -
flutter pub add intl:anyandflutter pub add flutter_localizations --sdk=flutter -
nano l10n.yamlwith: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
-
mkdir -p l10n && echo '{}' > l10n/app_en.arb && echo '{}' > l10n/untranslated.json -
Set
flutter.generateto true inpubspec.yamlflutter: generate: true # IMPORTANT to reproduce the issue
-
flutter pub getwithout any failures. Runflutter clean(IMPORTANT to reproduce) and thenmkdir app && mv * app/ -
nano pubspec.yamlwith:name: _ publish_to: none environment: sdk: ^3.9.0 workspace: - app
-
(cd app && flutter clean) && flutter clean -
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 getinside the app package first (example in a CI workflow). - Avoid setting
untranslated-messages-file. - Running
mkdir l10nat the workspace level and thenflutter pub getsolves the issue. Still, this is likely unexpected, because thel10n.yamlfile inside an app package should resolve its paths ofuntranslated-messages-filerelative to that package. - Update
untranslated-messages-fileto 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 runningflutter gen-l10ninside theappdirectory (wherel10n.yamlfile exists). Thearb-dirdirectory path does not need to be resolved from the root (l10ninstead ofapp/l10n) and works without any issues (also the case foroutput-dir). This indicates an issue withuntranslated-messages-file. - Set
flutter.generatetofalseinapp/pubspec.yaml, but thenflutter gen-l10nwill 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 availableAdditional context
Could be useful:
-
flutter/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart
Line 363 in 3b6c0bf
untranslated-messages-file: lib/l10n/untranslated.json