Dart-Code / Dart-Code

Dart and Flutter support for VS Code
https://dartcode.org/
MIT License
1.46k stars 295 forks source link

"Unable to find the library" regression? #5079

Closed techvx closed 1 month ago

techvx commented 1 month ago

Quite similar to #4932, yet with a slightly less verbose of an output this time around.

Describe the bug Any attempt to execute an expression in VS Code's debug console for a Flutter app running in debug mode prints back:

2 + 2
Unable to find the library for file:///e%3A/Development/_code/Flutter/app_6/lib/main.dart

To Reproduce Steps to reproduce the behavior:

  1. Create a new app via "Flutter: New Project".
  2. Build it for any platform - Windows or Web.
  3. Evaluate a 2 + 2 in the VSC debug console.

Expected behavior Having the debug console matching the output of the Flutter DevTools one.

Screenshots

image

image

Workspace Environment ```text Dart Code extension: 3.86.0 Flutter extension: 3.86.0 (activated) App: Visual Studio Code App Host: desktop Version: win 1.88.1 Workspace type: Flutter (LSP) Dart (3.3.3): \bin\cache\dart-sdk Flutter (3.19.5): ```
Output from 'dart info' `\bin\cache\dart-sdk\bin\dart.exe info` If providing this information as part of reporting a bug, please review the information below to ensure it only contains things you're comfortable posting publicly. #### General info - Dart 3.3.3 (stable) (Tue Mar 26 14:21:33 2024 +0000) on "windows_x64" - on windows / "Windows 10 Pro" 10.0 (Build 19045) - locale is en-US #### Project info - sdk constraint: '>=3.3.3 <4.0.0' - dependencies: cupertino_icons, flutter - dev_dependencies: flutter_lints, flutter_test - elided dependencies: 1 #### Process info | Memory | CPU | Elapsed time | Command line | | -----: | --: | -----------: | ------------ | | 47 MB | -- | | dart.exe | | 147 MB | -- | | dart.exe | | 77 MB | -- | | dart.exe | | 86 MB | -- | | dart.exe | | 151 MB | -- | | dart.exe | | 95 MB | -- | | dart.exe |
Output from 'flutter doctor' `\bin\flutter.bat doctor -v` ```text [✓] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19045.4291], locale en-US) • Flutter version 3.19.5 on channel stable at • Upstream repository https://github.com/flutter/flutter.git • Framework revision 300451adae (4 weeks ago), 2024-03-27 21:54:07 -0500 • Engine revision e76c956498 • Dart version 3.3.3 • DevTools version 2.31.1 [✓] Windows Version (Installed version of Windows is version 10 or higher) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at E:\Programs\AndroidSDK • Platform android-33, build-tools 30.0.3 • Java binary at: E:\Programs\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • 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 2019 16.11.21) • Visual Studio at E:\Development\VS\Community • Visual Studio Community 2019 version 16.11.33027.164 • Windows 10 SDK version 10.0.19041.0 [✓] Android Studio (version 4.2) • Android Studio at E:\Programs\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 = E:\Programs\Android Studio • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) [✓] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4291] • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.123 • Edge (web) • edge • web-javascript • Microsoft Edge 124.0.2478.51 [✓] Network resources • All expected network resources are available. • No issues found! ```

@DanTup

DanTup commented 1 month ago

The fix for https://github.com/Dart-Code/Dart-Code/issues/4932 was in the SDK so requires a new Dart/Flutter SDK to get it. The fix was made after the branch for the previous (Feb) release so will show up only in the next one.

If you're able to test on the beta branch, you should find it fixed - but if you still see the error there, please let me know!

techvx commented 1 month ago

Just switched to the beta, as confirmed by flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.22.0-0.2.pre, on Microsoft Windows [Version 10.0.19045.4291], locale en-US)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.21)
[✓] Android Studio (version 4.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

No luck, nevertheless:

Launching lib\main.dart on Windows in debug mode...
✓ Built build\windows\x64\runner\Debug\app_6.exe
Connecting to VM Service at ws://127.0.0.1:61484/Hh4qesxiJFs=/ws
2 + 2
Unable to find the library for file:///e%3A/Development/_code/Flutter/app_6/lib/main.dart
DanTup commented 1 month ago

Thanks for checking! Indeed, I can repro too - taking a look.

DanTup commented 1 month ago

Ok, I think I know what happened here. We used to mostly use file paths in the debug adapter, which meant the URI sent for context here was converted to a file path. VS Code escapes the colon in the file URI, but converting to a file path with decode that.

As part of work to support macros, much of the debug adapter was upgraded to use URIs (to support virtual documents that aren't on the disk), and that meant we no longer convert the URI back to a file path, but use it as-is. This meant the encoded colon in the drive letter was sent to the VM and didn't match, so some mapping didn't work correctly.

We can handle this in the VS Code extension by disabling VS Code's over-escaping.

DanTup commented 1 month ago

@techvx I've published a pre-release version of the extension that includes this fix (v3.87.20240423). If you get chance, would you be able to switch to it in VS Code and verify that with this version that it's working for you on Flutter beta or master?

Dart pre-release versions

You will have to click the "Reload" button after installing the new extension for it to become active.

Thanks!

techvx commented 1 month ago

It does work as intended now:

image

Thanks for the speed on this one.

DanTup commented 1 month ago

Great, thanks for confirming (and bringing it to my attention!)