Skip to content

DartUri: Cannot read packages spec in workspace environment #161469

@JHubi1

Description

@JHubi1

Steps to reproduce

Short: Create a flutter project inside a workspace and add a web target.

  1. Create an empty folder
  2. Add a pubspec.yaml with a name and workspace attribute
  3. Create a subfolder using flutter create --platforms=web -e app
  4. Add resolution: workspace to its pubspec.yaml and the package directory to the root pubspec
  5. Run the project in web

Expected results

Not to print anything (-> not to throw errors)

Actual results

DartUri: Cannot read packages spec: file:///C:/Users/jakob/Documents/GitHub/upsheep/packages/test_app/.dart_tool/package_config.jsonError: PathNotFoundException: Cannot open file, path = 'C:\Users\jakob\Documents\GitHub\upsheep\packages\test_app\.dart_tool\package_config.json' (OS Error: Das System kann die angegebene Datei nicht finden., errno = 2)

(second part is German and means something along the lines of "The system could not find the specified file")

I did some digging and by judging by previous issues, I believe this is an issue directly related to Flutter.
It occurs because pub get deletes said .dart_tool/package_config.json file and "relocates" it to the root project.

Running the project still works, but on every refresh the error is printed. Not very cool

Code sample

Code sample

Not applicable, see "Steps to reproduce"

Screenshots or Video

Screenshots / Video demonstration

Not applicable

Logs

The instructions say I have to add --verbose, it's quite a long output, so I also attached the output without verbose.

Logs without Verbose
C:\Users\jakob\Documents\GitHub\upsheep\packages\test_app>flutter run
Resolving dependencies in `C:\Users\jakob\Documents\GitHub\upsheep`...
Downloading packages...
  _fe_analyzer_shared 76.0.0 (78.0.0 available)
  analyzer 6.11.0 (7.1.0 available)
  async 2.11.0 (2.12.0 available)
  boolean_selector 2.1.1 (2.1.2 available)
  characters 1.3.0 (1.4.0 available)
  clock 1.1.1 (1.1.2 available)
  collection 1.19.0 (1.19.1 available)
  fake_async 1.3.1 (1.3.2 available)
  leak_tracker 10.0.7 (10.0.8 available)
  leak_tracker_flutter_testing 3.0.8 (3.0.9 available)
  matcher 0.12.16+1 (0.12.17 available)
  material_color_utilities 0.11.1 (0.12.0 available)
  meta 1.15.0 (1.16.0 available)
  path 1.9.0 (1.9.1 available)
  source_span 1.10.0 (1.10.1 available)
  stack_trace 1.12.0 (1.12.1 available)
  stream_channel 2.1.2 (2.1.4 available)
  string_scanner 1.3.0 (1.4.1 available)
  term_glyph 1.2.1 (1.2.2 available)
  test 1.25.8 (1.25.14 available)
  test_api 0.7.3 (0.7.4 available)
  test_core 0.6.5 (0.6.8 available)
  vm_service 14.3.0 (15.0.0 available)
Got dependencies in `C:\Users\jakob\Documents\GitHub\upsheep`!
23 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...             23,3s
DartUri: Cannot read packages spec: file:///C:/Users/jakob/Documents/GitHub/upsheep/packages/test_app/.dart_tool/package_config.jsonError:
PathNotFoundException: Cannot open file, path = 'C:\Users\jakob\Documents\GitHub\upsheep\packages\test_app\.dart_tool\package_config.json' (OS
Error: Das System kann die angegebene Datei nicht finden.
, errno = 2)
This app is linked to the debug service: ws://127.0.0.1:51345/YC9YGKFnjaI=/ws
Debug service listening on ws://127.0.0.1:51345/YC9YGKFnjaI=/ws

🔥  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".

A Dart VM Service on Chrome is available at: http://127.0.0.1:51345/YC9YGKFnjaI=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9102?uri=http://127.0.0.1:51345/YC9YGKFnjaI=

Application finished.

C:\Users\jakob\Documents\GitHub\upsheep\packages\test_app>
Logs with Verbose

This reveals a lot more DartUri errors than initially thought. Wow

Too long, see https://pastebin.com/PGQN912h

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.2605], locale de-DE)
    • Flutter version 3.27.1 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17025dd882 (4 weeks ago), 2024-12-17 03:23:09 +0900
    • Engine revision cb4b5fff73
    • Dart version 3.6.0
    • DevTools version 2.40.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\jakob\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35027.167
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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
    • android-studio-dir = C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[√] VS Code, 64-bit edition (version 1.96.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.102.0

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2605]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 131.0.6778.265

[√] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listfound in release: 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28has 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