Repository navigation
Description
--experimental-faster-testing cannot resolve the project's own package: URIs — regression in #169556
Steps to reproduce
On a path containing no hyphens (so #161083 is not also in play):
flutter create --project-name sample --platforms=macos sample
cd sample
rm test/widget_test.dart
echo 'const int answer = 42;' > lib/foo.dart
cat > test/one_test.dart <<'EOF'
import 'package:flutter_test/flutter_test.dart';
import 'package:sample/foo.dart';
void main() {
test('one', () => expect(answer, 42));
}
EOF
cat > test/two_test.dart <<'EOF'
import 'package:flutter_test/flutter_test.dart';
void main() {
test('two', () => expect(2 + 2, 4));
}
EOF
flutter pub get
flutter test test/one_test.dart test/two_test.dart # passes
flutter test --experimental-faster-testing test/one_test.dart test/two_test.dart # failsTwo test files are needed because the flag is ignored for a single file. one_test.dart must import the project's own package by package: URI — that is what triggers this. (--platforms is incidental; only lib/ and test/ matter.)
Expected results
Both commands pass.
Actual results
Plain flutter test passes (+2: All tests passed!). With --experimental-faster-testing:
test/one_test.dart:2:8: Error: Error when reading '../../lib/foo.dart': No such file or directory
import 'package:sample/foo.dart';
^
test/one_test.dart:5:28: Error: Undefined name 'answer'.
test('one', () => expect(answer, 42));
^^^^^^
00:00 +1 -1: Some tests failed.
Failing tests:
test/one_test.dart: one
Exit code 1. two_test.dart, which imports nothing from the project, still passes — only the file with the package: self-import fails. The import is a package URI, but it is reported as a missing relative path pointing outside the project.
Root cause
packages/flutter_tools/lib/src/test/runner.dart, in _generateIsolateSpawningTesterPackageConfig:
projectPackageConfig = PackageConfig.parseBytes(
packageConfigFile.readAsBytesSync(),
Uri.file(flutterProject.directory.path), // base URI
);PackageConfig.parseBytes resolves relative URIs against baseUri; its dartdoc says the base "can be the URI of that file, or of the directory it occurs in" — the package_config.json itself, or .dart_tool/. It is given the project directory instead, one level above .dart_tool/, and via Uri.file without a trailing slash, so the last segment is stripped as if it were a filename.
The generated project's root package entry is:
{"name": "sample", "rootUri": "../", "packageUri": "lib/", "languageVersion": "3.12"}Resolving "rootUri": "../" against the wrong base therefore lands two levels too high:
| base URI | "../" resolves to |
packageUri: "lib/" becomes |
|---|---|---|
/private/tmp/sample/.dart_tool/package_config.json (correct) |
/private/tmp/sample/ |
/private/tmp/sample/lib/ |
/private/tmp/sample (current) |
/private/ |
/private/lib/ |
/private/lib/foo.dart, printed by the CFE relative to the CWD, is exactly the reported ../../lib/foo.dart.
The two adjacent parseBytes call sites in the same file already pass a file URI — only the project's own config is given a directory path:
runner.dart:214,216 Uri.file(flutterProject.directory.path) <-- this bug
runner.dart:238,240 flutterToolsPackageConfigFile.uri <-- correct
runner.dart:633,635 isolateSpawningTesterPackageConfigFile.uri <-- correct
This is a regression
Introduced by #169556 ("Workspace", merged 2025-06-03):
packages/flutter_tools/lib/src/test/runner.dart
- projectPackageConfigFile.uri,
+ Uri.file(flutterProject.directory.path),Restoring packageConfigFile.uri as the base resolves it.
Reachability
This sits behind path sanitization. On 3.44.x, pathToImport uses a chained .replaceAll('.', '_').replaceAll(':', '_').replaceAll('/', '_') (runner.dart:277-282), so hyphenated paths fail earlier with invalid Dart identifiers (#161083) and never reach this. From 3.45.0-0.1.pre, pathToImport sanitizes with .replaceAll(RegExp(r'[^a-zA-Z0-9]'), '_') (runner.dart:283), so hyphenated paths now get through and hit this instead.
Relationship to existing issues
- Distinct from
--experimental-faster-testingdoesn't sanitize paths #161083 (path sanitization) — the bug that currently hides this one. - Distinct from flutter test: (includes patch) experimental faster testing - support for paths with '-' character and also workspaces #168657 — its patch predates this regression (3.29.2 still passed
projectPackageConfigFile.uri) and targets workspace lookup, not the base URI.
Versions
Reproduced with the steps above on:
3.44.6stable (ee80f08bbf, Dart 3.12.2) — base URI atrunner.dart:2163.47.0-0.4.prebeta (034409942b, 2026-08-04) — base URI atrunner.dart:219
Also present in 3.44.4 (runner.dart:216) and unchanged on master as of 2026-08-07.
Flutter doctor
flutter doctor -v (paths and device identifiers redacted)
[✓] Flutter (Channel stable, 3.44.6, on macOS 26.6.1 25G76 darwin-arm64, locale en-US) [208ms]
• Flutter version 3.44.6 on channel stable at /Users/USER/fvm/versions/3.44.6
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ee80f08bbf (4 weeks ago), 2026-07-08 15:02:06 -0700
• Engine revision 83675ed276
• Dart version 3.12.2
• DevTools version 2.57.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, no-enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [728ms]
• Android SDK at /Users/USER/Library/Android/sdk
• Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
• Platform android-36.1, build-tools 35.0.1
• Java binary at: /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.20+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 26.6) [459ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17F113
• CocoaPods version 1.17.0
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (4 available) [5.8s]
• <device> • <redacted> • ios • iOS 26.5.2 23F84
• <device> • <redacted> • ios • iOS 26.6 23G71
• macOS (desktop) • macos • darwin-arm64 • macOS 26.6.1 25G76 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 151.0.7922.109
! Error: Browsing on the local area network for <device>. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for <device>. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources [407ms]
• All expected network resources are available.
• No issues found!
Activity
saurabh-mirajkar commentedon Aug 10, 2026
@vladimir-ionita Thanks for the detailed report. This appears to be related to #161083, #168657. I was able to reproduce this on Flutter
3.44.9stable with the provided steps. Routing this for further investigation.Flutter Doctor
[flutter_tools] Fix package URI resolution in --experimental-faster-t…
github-actions commentedon Aug 25, 2026
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 -vand a minimal reproduction of the issue.