Skip to content

[flutter_tools] Exit cleanly when Windows path exceeds MAX_PATH (OS Error 206) - #194867

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
bkonyi:fix-194570-windows-path-too-long
Oct 21, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
bkonyi:fix-194570-windows-path-too-long

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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

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

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 #194570

…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
@bkonyi bkonyi added tool Affects the "flutter" command-line tool. See also t: labels. CICD Run CI/CD and removed CICD Run CI/CD labels Oct 20, 2026
@bkonyi
bkonyi marked this pull request as ready for review October 20, 2026 15:53
@bkonyi
bkonyi requested a review from jyameo October 20, 2026 15:54
@bkonyi bkonyi added the t: cp-candidate A PR that should be considered for a cherry-pick upon landing. label Oct 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jyameo jyameo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit

auto-submit Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit

auto-submit Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit

auto-submit Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into flutter:master with commit b5d156b Oct 21, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Oct 22, 2026
…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
@bkonyi bkonyi added cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch labels Oct 22, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch t: cp-candidate A PR that should be considered for a cherry-pick upon landing. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tool_crash] Unhandled ProcessPackageException (OS Error 206: The filename or extension is too long) in _DefaultPub._preloadPubCache

3 participants