Skip to content

dap-debug: Dart library 'dart:ui' is not available on this platform #231

@shenso

Description

@shenso

Describe the bug
Upon starting a debug session from my configuration in .vscode/launch.json, I get spammed with endless errors, all ultimately explained by the first few lines of the debug output:

../../.local/opt/flutter/packages/flutter/lib/src/widgets/app.dart:45:1: Error: Dart library 'dart:ui' is not available on this platform.
export 'dart:ui' show Locale;
^

To Reproduce

My emacs configuration on MacOS:

(use-package dart-mode
  :if (member system-name dart-systems)
  :ensure t
  :config
  (use-package flutter
    :ensure t
    :init
    (setq flutter-sdk-path (expand-file-name "~/.local/opt/flutter")))

  (use-package lsp-dart
    :if (member system-name lsp-systems)
    :requires lsp-mode
    :after flutter
    :ensure t
    :hook (dart-mode . lsp)
    :init
    (setq lsp-dart-sdk-dir (expand-file-name "~/.local/opt/flutter/bin/cache/dart-sdk")
          lsp-dart-flutter-sdk-dir (expand-file-name "~/.local/opt/flutter")
          lsp-dart-dap-use-sdk-debugger t)
    (dap-register-debug-template "Flutter :: Custom debug"
                                 (list :type "flutter"
                                       :program "lib/main_development.dart"
                                       :args '("--web-browser-flag"
                                               "--disable-web-security"
                                               "--flavor"
                                               "development"
                                               "--target"
                                               "lib/main_development.dart"
                                               "--web-port"
                                               "5555")))
    :config
    (setq gc-cons-threshold (* 100 1024 1024)
          read-process-output-max (* 1024 1024))))

I've tried keeping the sdk dirs as relative paths, keeping them unset, I've tried switching between which debugger is used and the result is the same. You can see I also created a custom debug template working off the guidelines in the README, but due to #226 / #222 this has just caused different problems.

My launch.json:

        {
            "name": "Launch development",
            "request": "launch",
            "type": "dart",
            "program": "lib/main_development.dart",
            "args": [
                "--web-browser-flag",
                "--disable-web-security",
                "--flavor",
                "development",
                "--target",
                "lib/main_development.dart",
                "--web-port",
                "5555"
            ]
        },

I've tried changing the type to "flutter" but that seems to have no effect.

Expected behavior

I would expect things to just work when selecting the configuration after invoking dap-debug just as they do on vscode.

Version

LSP Dart: 1.24.3
Dart SDK: 3.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions