Repository navigation
[flutter_tools] Exit cleanly when Windows path exceeds MAX_PATH (OS Error 206) - #194867
Conversation
…rror 206) When a Flutter project, SDK, or subprocess command path on Windows exceeds `MAX_PATH` (260 characters), Win32 process and file operations fail with OS error code `206` (`ERROR_FILENAME_EXCED_RANGE`: `The filename or extension is too long`). Previously, `_handleWindowsException` in `error_handling_io.dart` did not recognize error code `206`, causing `ErrorHandlingProcessManager` and `ErrorHandlingFileSystem` to rethrow an unhandled `ProcessPackageException` or `FileSystemException` and trigger a crash report. Add `kFilenameExcedRange = 206` to `_handleWindowsException` so operations failing with error code `206` exit cleanly with a `ToolExit` instructing the user to move the Flutter SDK and/or project to a shorter path or enable long paths on Windows. ### Previous output ```text Unhandled exception: ProcessPackageException: ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... #0 LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118) #1 ErrorHandlingProcessManager.runSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:1310) #2 _runSync (package:flutter_tools/src/base/error_handling_io.dart:1118) #3 ErrorHandlingProcessManager.runSync (package:flutter_tools/src/base/error_handling_io.dart:1308) #4 _DefaultPub._preloadPubCache (package:flutter_tools/src/dart/pub.dart:645) ``` ### Current output ```text Flutter failed to run "C:\Users\User\AppData\Local\Temp\...". The filename or extension is too long. ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... Please consider moving the Flutter SDK and/or project to a shorter path, or enabling long paths on Windows. ``` Fixes flutter#194570
There was a problem hiding this comment.
Code Review
This pull request introduces handling for the Windows error code 206 (kFilenameExcedRange) to provide a clear error message when a path or filename is too long, and adds corresponding tests. The review feedback highlights issues in the new tests where asynchronous operations are not properly awaited, which could lead to concurrent execution and test flakiness, and suggests using await expectLater to ensure sequential execution.
…_handling_io_test
|
autosubmit label was removed for flutter/flutter/194867, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/194867, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/194867, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…indows-path-too-long
…rror 206) (flutter#194867) When a Flutter project, SDK, or subprocess command path on Windows exceeds `MAX_PATH` (260 characters), Win32 process and file operations fail with OS error code `206` (`ERROR_FILENAME_EXCED_RANGE`: `The filename or extension is too long`). Previously, `_handleWindowsException` in `error_handling_io.dart` did not recognize error code `206`, causing `ErrorHandlingProcessManager` and `ErrorHandlingFileSystem` to rethrow an unhandled `ProcessPackageException` or `FileSystemException` and trigger a crash report. Add `kFilenameExcedRange = 206` to `_handleWindowsException` so operations failing with error code `206` exit cleanly with a `ToolExit` instructing the user to move the Flutter SDK and/or project to a shorter path or enable long paths on Windows. ### Previous output ```text Unhandled exception: ProcessPackageException: ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... #0 LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118) #1 ErrorHandlingProcessManager.runSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:1310) #2 _runSync (package:flutter_tools/src/base/error_handling_io.dart:1118) flutter#3 ErrorHandlingProcessManager.runSync (package:flutter_tools/src/base/error_handling_io.dart:1308) flutter#4 _DefaultPub._preloadPubCache (package:flutter_tools/src/dart/pub.dart:645) ``` ### Current output ```text Flutter failed to run "C:\Users\User\AppData\Local\Temp\...". The filename or extension is too long. ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... Please consider moving the Flutter SDK and/or project to a shorter path, or enabling long paths on Windows. ``` Fixes flutter#194570
|
Failed to create CP due to merge conflicts. |
…rror 206) (flutter#194867) When a Flutter project, SDK, or subprocess command path on Windows exceeds `MAX_PATH` (260 characters), Win32 process and file operations fail with OS error code `206` (`ERROR_FILENAME_EXCED_RANGE`: `The filename or extension is too long`). Previously, `_handleWindowsException` in `error_handling_io.dart` did not recognize error code `206`, causing `ErrorHandlingProcessManager` and `ErrorHandlingFileSystem` to rethrow an unhandled `ProcessPackageException` or `FileSystemException` and trigger a crash report. Add `kFilenameExcedRange = 206` to `_handleWindowsException` so operations failing with error code `206` exit cleanly with a `ToolExit` instructing the user to move the Flutter SDK and/or project to a shorter path or enable long paths on Windows. ### Previous output ```text Unhandled exception: ProcessPackageException: ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... #0 LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118) flutter#1 ErrorHandlingProcessManager.runSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:1310) flutter#2 _runSync (package:flutter_tools/src/base/error_handling_io.dart:1118) flutter#3 ErrorHandlingProcessManager.runSync (package:flutter_tools/src/base/error_handling_io.dart:1308) flutter#4 _DefaultPub._preloadPubCache (package:flutter_tools/src/dart/pub.dart:645) ``` ### Current output ```text Flutter failed to run "C:\Users\User\AppData\Local\Temp\...". The filename or extension is too long. ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... Please consider moving the Flutter SDK and/or project to a shorter path, or enabling long paths on Windows. ``` Fixes flutter#194570
When a Flutter project, SDK, or subprocess command path on Windows exceeds
MAX_PATH(260 characters), Win32 process and file operations fail with OS error code206(ERROR_FILENAME_EXCED_RANGE:The filename or extension is too long). Previously,_handleWindowsExceptioninerror_handling_io.dartdid not recognize error code206, causingErrorHandlingProcessManagerandErrorHandlingFileSystemto rethrow an unhandledProcessPackageExceptionorFileSystemExceptionand trigger a crash report.Add
kFilenameExcedRange = 206to_handleWindowsExceptionso operations failing with error code206exit cleanly with aToolExitinstructing the user to move the Flutter SDK and/or project to a shorter path or enable long paths on Windows.Previous output
Current output
Fixes #194570