Skip to content

Flutter widget preview server crashes when running "flutter clean" #175058

@DanTup

Description

@DanTup

When I trigger flutter clean and the preview server is running in VS Code, it terminates with the exception below.

(cc @bkonyi)

command

flutter widget-preview start --machine --web-server --dtd-url ws://127.0.0.1:54473/XO21bCX2tyE= --devtools-server-address http://127.0.0.1:9100/

exception

PathNotFoundException: PathNotFoundException: Cannot open file, path = 'D:\Dev\Test Projects\flutter_counter.dart_tool\widget_preview_scaffold\lib\src\generated_preview.dart' (OS Error: The system cannot find the path specified.
, errno = 3)

#0      _File.throwIfError (dart:io/file_impl.dart:783:7)
#1      _File.openSync (dart:io/file_impl.dart:576:5)
#2      _File.writeAsBytesSync (dart:io/file_impl.dart:748:31)
#3      _File.writeAsStringSync (dart:io/file_impl.dart:776:5)
#4      ForwardingFile.writeAsStringSync (package:file/src/forwarding/forwarding_file.dart:150:16)
#5      ErrorHandlingFile.writeAsStringSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:254:22)
#6      _runSync (package:flutter_tools/src/base/error_handling_io.dart:552:14)
#7      ErrorHandlingFile.writeAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:253:5)
#8      PreviewCodeGenerator.populatePreviewsInGeneratedPreviewScaffold (package:flutter_tools/src/widget_preview/preview_code_generator.dart:109:26)
#9      WidgetPreviewStartCommand.runCommand (package:flutter_tools/src/commands/widget_preview.dart:336:27)
<asynchronous suspension>
#10     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1559:27)
<asynchronous suspension>
#11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#12     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#13     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:487:9)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#15     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:422:5)
<asynchronous suspension>
#16     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:101:11)
<asynchronous suspension>
#17     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#18     main (package:flutter_tools/executable.dart:102:3)
<asynchronous suspension>

flutter doctor

[!] Flutter (Channel [user-branch], 3.36.0-1.0.pre-451, on Microsoft Windows [Version 10.0.26100.4946], locale en-GB) [206ms]
    ! Flutter version 3.36.0-1.0.pre-451 on channel [user-branch] at D:\Dev\Google\Flutter\Flutter main
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Warning: `dart` on your path resolves to D:\Tools\Dart\Stable\bin\dart.exe, which is not inside your current Flutter SDK checkout at D:\Dev\Google\Flutter\Flutter main. Consider adding D:\Dev\Google\Flutter\Flutter main\bin to the front of your path.
    ! Upstream repository [email protected]:DanTup/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to [email protected]:DanTup/flutter.git to dismiss this error.
    • Framework revision c6b9900f46 (22 minutes ago), 2025-09-08 09:19:47 +0100
    • Engine revision 937f2b9ad4
    • Dart version 3.10.0 (build 3.10.0-180.0.dev)
    • DevTools version 2.50.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Windows Version (11 Pro 64-bit, 24H2, 2009) [790ms]

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.5s]
    • Android SDK at C:\Users\danny\AppData\Local\Android\sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [62ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [61ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35122.118
    • Windows 10 SDK version 10.0.26100.0

[✓] Connected device (3 available) [75ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.4946]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 139.0.7258.155
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 139.0.3405.119

[✓] Network resources [710ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.
[11:19:08 AM] [FlutterWidgetPreview] [Info] Spawning D:\Dev\Google\Flutter\Flutter main\bin\flutter.bat with args ["widget-preview","start","--machine","--web-server","--dtd-url","ws://127.0.0.1:54473/XO21bCX2tyE=","--devtools-server-address","http://127.0.0.1:9100/"]
[11:19:08 AM] [FlutterWidgetPreview] [Info] ..  in D:\Dev\Test Projects\flutter_counter
[11:19:08 AM] [FlutterWidgetPreview] [Info] ..  with {"toolEnv":{"FLUTTER_HOST":"VSCode","PUB_ENVIRONMENT":"vscode.dart-code","FLUTTER_ROOT":"D:\\Dev\\Google\\Flutter\\Flutter main"}}
[11:19:08 AM] [FlutterWidgetPreview] [Info]     PID: 18736
[11:19:19 AM] [FlutterWidgetPreview] [Error] 
[11:19:19 AM] [FlutterWidgetPreview] [Error] Oops; flutter has exited unexpectedly: "PathNotFoundException: Cannot open file, path = 'D:\Dev\Test Projects\flutter_counter\.dart_tool\widget_preview_scaffold\lib\src\generated_preview.dart' (OS Error: The system cannot find the path specified.
, errno = 3)".
[11:19:22 AM] [FlutterWidgetPreview] [Error] A crash report has been written to D:\Dev\Test Projects\flutter_counter\.dart_tool\widget_preview_scaffold\flutter_01.log
[11:19:22 AM] [FlutterWidgetPreview] [Info] <== This crash may already be reported. Check GitHub for similar crashes.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processplatform-windowsBuilding on or for Windows specificallyr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions