Skip to content

--experimental-faster-testing cannot resolve the project's own package: URIs — regression in #169556 #190784

Closed

Description

@vladimir-ionita

--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 # fails

Two 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

Versions

Reproduced with the steps above on:

  • 3.44.6 stable (ee80f08bbf, Dart 3.12.2) — base URI at runner.dart:216
  • 3.47.0-0.4.pre beta (034409942b, 2026-08-04) — base URI at runner.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

  1. saurabh-mirajkar commented on Aug 10, 2026

    @saurabh-mirajkar
    Contributor

    @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.9 stable with the provided steps. Routing this for further investigation.

    Flutter Doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.44.9, on macOS 26.6.1 25G76 darwin-arm64, locale en-IN) [169ms]
        • Flutter version 3.44.9 on channel stable at /Users/admin/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 6b182d2c75 (5 days ago), 2026-08-05 10:04:07 -0700
        • Engine revision 5a2a6a42cc
        • 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 37.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 26.6)
    [✓] Chrome - develop for the web
    [✓] Connected device (3 available)
    [✓] Network resources
    
  2. added
    c: regressionIt was better in the past than it is now
    toolAffects the "flutter" command-line tool. See also t: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Aug 10, 2026
  3. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Aug 10, 2026
  4. self-assigned this
    on Aug 10, 2026
  5. added a commit that references this issue on Aug 11, 2026
    05ee849
  6. github-actions commented on Aug 25, 2026

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

  7. locked as resolved and limited conversation to collaborators on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowfound in release: 3.44Found to occur in 3.44has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-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