Flutter Failed to start DevTools: Dart DevTools exited with code 255

eye-catchDart and Flutter
Sponsored links

The error described on the title occurred after I updated SDK tools by "sdkmanager --update" command.

Sponsored links

How to check Log info

I followed the steps below to get the log info.

  1. Execute “Dart: Capture Logs” from command pallet (shortcut button F1)

2. Execute “Dart: Open DevTools”

3. Wait for DevTools’ error
4. Cancel the log

After clicking the cancel log, the log file is opened. This is the log info.

!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.29.0
Flutter extension: 3.29.0 (activated)

App: Visual Studio Code
Version: 1.61.2
Platform: win

Workspace type: Flutter
Analyzer type: LSP
Multi-root?: false

Dart SDK:
    Loc: <path to your flutter directory>\bin\cache\dart-sdk
    Ver: 2.14.0
Flutter SDK:
    Loc: <path to your flutter directory>
    Ver: 2.5.0

HTTP_PROXY: undefined
NO_PROXY: undefined

Logging Categories:
    General, Analyzer, CommandProcesses, DartTest, DAP, VmService, DevTools, FlutterDaemon, FlutterRun, FlutterTest, WebDaemon

Tue Dec 21 2021 [08:07:55 GMT+0100 (中央ヨーロッパ標準時)] Log file started
[8:07:59] [General] [Info] Spawning <path to your flutter directory>\bin\cache\dart-sdk\bin\dart.exe with args ["pub","global","activate","devtools"]
[8:07:59] [CommandProcesses] [Info] (PROC 10596) Logging data for process...
[8:07:59] [CommandProcesses] [Info] (PROC 10596) Package devtools is currently active at version 2.9.2.
[8:07:59] [CommandProcesses] [Info] (PROC 10596)
[8:07:59] [CommandProcesses] [Info] (PROC 10596) Resolving dependencies...
[8:08:02] [CommandProcesses] [Info] (PROC 10596) The package devtools is already activated at newest available version.
[8:08:02] [CommandProcesses] [Info] (PROC 10596) 
To recompile executables, first run `global deactivate devtools`.
[8:08:02] [CommandProcesses] [Info] (PROC 10596)
[8:08:02] [CommandProcesses] [Info] (PROC 10596) Installed executable devtools.
[8:08:02] [CommandProcesses] [Info] (PROC 10596)
[8:08:03] [CommandProcesses] [Info] (PROC 10596) Warning: Pub installs executables into C:\Users\<user_name>\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
[8:08:03] [CommandProcesses] [Info] (PROC 10596)
[8:08:03] [CommandProcesses] [Info] (PROC 10596) Activated devtools 2.9.2.
[8:08:03] [CommandProcesses] [Info] (PROC 10596) exited (0, null)
[8:08:03] [CommandProcesses] [Info] (PROC 10596) closed (0, null)
[8:08:03] [General] [Info] Spawning <path to your flutter directory>\bin\cache\dart-sdk\bin\dart.exe with args ["pub","global","run","devtools","--machine","--try-ports","10","--allow-embedding"]
[8:08:03] [General] [Info] ..  with {"toolEnv":{"FLUTTER_HOST":"VSCode","PUB_ENVIRONMENT":"vscode.dart-code"}}
[8:08:03] [General] [Info]     PID: 2644
[8:08:05] [General] [Error] Unhandled exception:
Invalid argument(s): A directory corresponding to fileSystemPath "C:\Users\<user_name>\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\devtools-2.9.2\build" could not be found
#0      createStaticHandler (package:shelf_static/src/static_handler.dart:50:5)
#1      defaultHandler (package:devtools_server/src/external_handlers.dart:38:23)
<asynchronous suspension>
#2      serveDevTools (package:devtools_server/src/server.dart:215:15)
<asynchronous suspension>
#3      serveDevToolsWithArgs (package:devtools_server/src/server.dart:73:10)
<asynchronous suspension>
[8:08:05] [General] [Info] Process terminated! 255, null
[8:08:05] [General] [Error] Dart DevTools exited with code 255.
Tue Dec 21 2021 [08:08:11 GMT+0100 (中央ヨーロッパ標準時)] Log file ended

As the error message said, the build folder didn’t exist there when I checked it. It seems that the DevTools are integrated into Dart SDK.

Sponsored links

What I did to solve the problem

Delete Flutter cache folder (Not work)

I tried to delete the cache folder but it didn’t solve the problem.

Update Dart SDK

The next thing that I did was to update the dart SDK version. I updated the version from 2.14.0 to 2.15.1 because it is the latest stable version as of 2021-12-21. I re-opened VSCode after I installed it but Flutter didn’t startup instead.

[flutter] flutter doctor -v
Can't load Kernel binary: Invalid kernel binary format version.
exit code 253

Upgrade Flutter SDK

I deleted “<path to your flutter directory>\bin\cache” folder and re-opened VSCode. The download started automatically at the startup with the following message. It takes a while to download everything it needs.

Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine ...

The complete message is as follows.

Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine ... 
Expanding downloaded archive...
Building flutter tool... 
Running pub upgrade... 
╔════════════════════════════════════════════════════════════════════════════╗
║ A new version of Flutter is available!                                     ║
║                                                                            ║
║ To update to the latest version, run "flutter upgrade".                    ║
╚════════════════════════════════════════════════════════════════════════════╝

Downloading Material fonts...                                       4.3s
Downloading Gradle Wrapper...                                      236ms
Downloading package sky_engine...                                   4.1s
Downloading flutter_patched_sdk tools...                            5.9s
Downloading flutter_patched_sdk_product tools...                    9.2s
Downloading windows-x64 tools...                                   42.1s
Downloading windows-x64/font-subset tools...                     2,653ms
[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.19044.1415], locale ja-JP)
    • Flutter version 2.5.0 at <path to your flutter directory>\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (3 months ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
    • Android SDK at <path to your sdk directory>\sdk-tools-windows-4333796
    • Platform android-30, build-tools 30.0.0-rc4
    • Java binary at: C:\Program Files\Java\jdk1.8.0_161\bin\java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
    • All Android licenses accepted.

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

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] IntelliJ IDEA Community Edition (version 2019.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.2
    • 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

[√] IntelliJ IDEA Community Edition (version 2020.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1
    • 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

[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1.3
    • 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

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

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 96.0.1054.62

! Doctor found issues in 1 category.
exit code 0

But DevTools didn’t start up again when I tried to run it from the command pallet. When I checked the version, Dart version was still 2.14.0.

$ flutter --version
Flutter 2.5.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4cc385b4b8 (3 months ago) • 2021-09-07 23:01:49 -0700
Engine • revision f0826da7ef
Tools • Dart 2.14.0

Therefore, I upgraded Flutter version by “flutter upgrade”

$ flutter upgrade
Upgrading Flutter to 2.8.1 from 2.5.0 in <path to your flutter directory>\flutter...
Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine 890a5fca2e34db413be624fc83aeea8e61d42ce6... 
Expanding downloaded archive...
Building flutter tool... 
Running pub upgrade... 

Upgrading engine...
Downloading android-arm-profile/windows-x64 tools...                4.4s
Downloading android-arm-release/windows-x64 tools...                3.6s
Downloading android-arm64-profile/windows-x64 tools...           2,117ms
Downloading android-arm64-release/windows-x64 tools...           2,382ms
Downloading android-x64-profile/windows-x64 tools...                3.2s
Downloading android-x64-release/windows-x64 tools...                4.9s
Downloading android-x86 tools...                                   17.6s
Downloading android-x64 tools...                                   13.0s
Downloading android-arm tools...                                    6.0s
Downloading android-arm-profile tools...                            3.9s
Downloading android-arm-release tools...                         2,598ms
Downloading android-arm64 tools...                                  6.1s
Downloading android-arm64-profile tools...                          4.6s
Downloading android-arm64-release tools...                       2,681ms
Downloading android-x64-profile tools...                            3.4s
Downloading android-x64-release tools...                            3.3s
Downloading android-x86-jit-release tools...                        4.5s

It works after reload!

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1415], locale ja-JP)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
[√] Chrome - develop for the web  
[!] Android Studio (not installed)
[√] IntelliJ IDEA Community Edition (version 2019.1)
[√] IntelliJ IDEA Community Edition (version 2020.2)
[√] IntelliJ IDEA Community Edition (version 2021.1)
[√] VS Code, 64-bit edition (version 1.61.2)
[√] Connected device (2 available)

! Doctor found issues in 1 category.


$ flutter --version
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (5 days ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

When I started DevTools with log info, the correct versions are used as expected.

!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.29.0
Flutter extension: 3.29.0 (activated)

App: Visual Studio Code
Version: 1.61.2
Platform: win

Workspace type: Flutter
Analyzer type: LSP
Multi-root?: false

Dart SDK:
    Loc: <path to your flutter directory>\bin\cache\dart-sdk
    Ver: 2.15.1
Flutter SDK:
    Loc: <path to your flutter directory>
    Ver: 2.8.1

HTTP_PROXY: undefined
NO_PROXY: undefined

Logging Categories:
    General, Analyzer, CommandProcesses, DartTest, DAP, VmService, DevTools, FlutterDaemon, FlutterRun, FlutterTest, WebDaemon

Tue Dec 21 2021 [08:58:27 GMT+0100 (中央ヨーロッパ標準時)] Log file started
[8:58:31] [General] [Info] Opening external URL: http://127.0.0.1:9100/
[8:58:36] [General] [Info] Opening external URL: http://127.0.0.1:9100/
Tue Dec 21 2021 [08:58:42 GMT+0100 (中央ヨーロッパ標準時)] Log file ended

For Different Errors

If you have a different error message, this post might be helpful.

Comments

  1. Right Guy says:

    You did all that for nothing. “flutter upgrade” fixes this genius.

  2. Guest says:

    Yes flutter upgrade solved the issue! thanks buddy!

  3. Renato Bertone says:

    Grato!!! Apanhando alguns dias, salvou me!!!
    parabéns pela abordagem ampla…

Copied title and URL