Repository navigation
DartUri: Cannot read packages spec in workspace environment #161469
Description
Steps to reproduce
Short: Create a flutter project inside a workspace and add a web target.
- Create an empty folder
- Add a
pubspec.yamlwith anameandworkspaceattribute - Create a subfolder using
flutter create --platforms=web -e app - Add
resolution: workspaceto itspubspec.yamland the package directory to the root pubspec - 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!
Activity
ERGataullin commentedon Jan 11, 2025
Got the same problem yesterday
This way the app in workspace becomes not debuggable, because flutter can't understand paths to packages, causing not working breakpoints
Makes workspaces feature unusable
huycozy commentedon Jan 13, 2025
Hi @JHubi1
Can you please be more specific on "workspace" here? Is it just a simple folder or Is there any specific setup/configuration?
ERGataullin commentedon Jan 13, 2025
@huycozy, it's a Pub Workspace
JHubi1 commentedon Jan 13, 2025
Yes, Dart Workspaces. I believe this issue should have quite a high priority. Flutter not working with a native Dart feature is something that should not be a thing
davidmigloz commentedon Jan 13, 2025
After migrating to workspaces (Flutter 3.27.1 / Dart 3.6.0), I also started facing this issue on web
in combination with random(update: theTypeErrors:TypeErrors were caused by a dependency)Stacktrace
It only happens in debug mode, release builds work fine.
Similar issue: #161504
huycozy commentedon Jan 14, 2025
@JHubi1 Can you please provide a a completed and minimal reproducible code sample in a GitHUb repository? And please add a license in the repository under some open-source license (e.g. MIT, Apache, BSD, GPL) so that we may look into it. Thanks!
JHubi1 commentedon Jan 14, 2025
@huycozy created it here: https://github.com/JHubi1/flutter_issue_example_161469
Hope it works (or better not)
huycozy commentedon Jan 15, 2025
Thank you so much for the repo. Reproduced the issue on Flutter Channel master, ``3.28.0-2.0.pre.38724`. Although the app can run, there is error message from the output console:
Output log
3 remaining items
ERGataullin commentedon Jan 24, 2025
Reproducible in 3.27.3
bkonyi commentedon Jan 28, 2025
FYI @sigurdm, can you take a look?
sigurdm commentedon Jan 30, 2025
Seems like the message comes from here: https://github.com/dart-lang/webdev/blob/a7ea61ffa07e899fe7bcb385f8cbca88427e0c0a/dwds/lib/src/utilities/dart_uri.dart#L216
If I'm not wrong the LoadStrategy is provided by flutter tools here:
flutter/packages/flutter_tools/lib/src/isolated/devfs_web.dart
Line 335 in 6d2792d
nullas packageConfigUri - I think that it should instead get the packageConfigUri from BuildInfo somehow - probably requires an update to package:dwds.@srujzs and @jyameo might have more context.
srujzs commentedon Jan 30, 2025
It should be calling https://github.com/dart-lang/webdev/blob/a7ea61ffa07e899fe7bcb385f8cbca88427e0c0a/dwds/lib/src/loaders/frontend_server_strategy_provider.dart#L171 by default, but the effect is the same in that we don't store a
packageConfigPath. Let me see if trying out what @sigurdm suggested works.srujzs commentedon Jan 31, 2025
FYI - it looks like it avoids the issues (the aforementioned logs do not appear). There is a similar issue on the webdev side: dart-lang/webdev#2575. DWDS should be updated to accept and use the path for every strategy, and Flutter tools should be updated to pass it. I'll work with @jyameo here to land a change.
sigurdm commentedon Jan 31, 2025
Thanks!
jyameo commentedon Feb 11, 2025
I have published a new version of
DWDS v24.3.5with the fix for this issue. I believe it should be pickup on the next flutter release.explicitly set packageConfigPath for strategy providers (#163080)
github-actions commentedon Feb 26, 2025
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.