Skip to content

"Unable to find the library" for global evaluation when the current file is inside the lib folder #4932

@techvx

Description

@techvx

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:

1 + 1
Unable to find the library for file:///e%3A/Development/_code/Flutter/app_5/lib/main.dart
#0      DartDebugAdapter.evaluateRequest (package:dds/src/dap/adapters/dart.dart:1060:7)
<asynchronous suspension>
#1      BaseDebugAdapter.handle (package:dds/src/dap/base_debug_adapter.dart:141:7)
<asynchronous suspension>

To Reproduce
Steps to reproduce the behavior:

  1. Create a new app via "Flutter: New Project".
  2. Build it for Windows, in my case.
  3. Attempt to evaluate any expression in VSC's debug console.
  4. Observe the unable to find the library aforementioned error from above.

Expected behavior
Prior to the most recent upgrade to Flutter 3+ and Dart SDK 3.2.3, it was perfectly possible not only to evaluate arbitrary operations in global context, but also to reference the declarations in the main.dart directly. This was extremely useful for custom debugging, which would allow for inspection of surgical precision within any runtime object that required additional monitoring, as needed.

It would be most useful to get such an option back. Running the DevTools (2.28.4) directly in the browser, furthermore, still allows to do just that - at any point in time, with or without the breakpoint. DevTools aren't nearly as versatile and free of friction as the standard built-in debug console within VSC, however. Having to go back and forth in and out of the IDE adds quite a bit of additional mental overhead as well, which doesn't exactly feel as absolutely necessary.

I see that the #4636 issue was closed as completed. Can this be considered a regression? The #4899 appears to have similar working, though the context seems to be limited to Dart only, with no mentioning of Flutter. The exact error appears to be different too, here.

Screenshots

compare the debug console:

image

to the DevTools console:

image

Diagnostics

Workspace Environment
Dart Code extension: 3.80.0
Flutter extension: 3.80.0 (activated)

App: Visual Studio Code
App Host: desktop
Version: win 1.85.1

Workspace type: Flutter (LSP)

Dart (3.2.3): E:\Development\Flutter\3.3.10\bin\cache\dart-sdk
Flutter (3.16.6): E:\Development\Flutter\3.3.10 (Windows (windows-x64/windows))

Output from `dart info`

E:\Development\Flutter\3.3.10\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.2.3 (stable) (Tue Dec 5 17:58:33 2023 +0000) on "windows_x64"
  • on windows / "Windows 10 Pro" 10.0 (Build 19045)
  • locale is en-US

Project info

  • sdk constraint: '>=3.2.3 <4.0.0'
  • dependencies: flutter
  • dev_dependencies: flutter_lints, flutter_test
  • elided dependencies: 2

Process info

Memory CPU Elapsed time Command line
82 MB -- dart.exe
14 MB -- dart.exe
39 MB -- dart.exe
456 MB -- dart.exe
47 MB -- dart.exe
41 MB -- dart.exe
86 MB -- dart.exe
126 MB -- dart.exe
374 MB -- dart.exe
85 MB -- dart.exe
Output from `flutter doctor`

E:\Development\Flutter\3.3.10\bin\flutter.bat doctor -v

[√] Flutter (Channel stable, 3.16.6, on Microsoft Windows [Version 10.0.19045.3930], locale en-US)
    • Flutter version 3.16.6 on channel stable at E:\Development\Flutter\3.3.10
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 46787ee49c (2 days ago), 2024-01-09 14:36:07 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[√] 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.3930]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 120.0.6099.217
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 120.0.2210.121

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsis bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions