Skip to content

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

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-194867-to-stable
Oct 26, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-194867-to-stable

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#194570

Impact Description:

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 (#10 top crasher in Flutter 3.47.7). This change handles error code 206 and exits cleanly with a ToolExit message guiding the user to move the Flutter SDK and/or project to a shorter path or enable long paths on Windows.

Conflict Resolution (stable): Resolved a trivial merge conflict in _handleWindowsException (packages/flutter_tools/lib/src/base/error_handling_io.dart) caused by error code constant ordering differences between flutter-3.47-candidate.0 and master.

Changelog Description:

[flutter/194570] When a path or command exceeds MAX_PATH on Windows (OS Error 206), flutter_tools crashed with an unhandled ProcessPackageException or FileSystemException instead of exiting cleanly with an actionable error message.

Workaround:

Move the Flutter SDK and/or project to a shorter directory path, enable Windows Long Paths, or set PUB_CACHE / delete $FLUTTER_ROOT/.pub-preload-cache if hit during initial pub cache preload.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

Run a flutter command (such as flutter pub get) on Windows where a file or subprocess command fails with OS error 206 (ERROR_FILENAME_EXCED_RANGE), or run flutter test test/general.shard/base/error_handling_io_test.dart, and verify that flutter_tools exits cleanly with a ToolExit message rather than an unhandled exception crash.

…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.

```text
Unhandled exception:
ProcessPackageException: ProcessException: The filename or extension is too long
  Command: C:\Users\User\AppData\Local\Temp\...
```

```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 CICD Run CI/CD cp: review Cherry-picks in the review queue labels Oct 22, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 22, 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 (filename or extension too long) by displaying a helpful error message that suggests moving the project to a shorter path or enabling long paths. It also adds comprehensive unit tests to verify this behavior for both file system operations and process execution. Feedback is provided to use single quotes instead of double quotes within string interpolation to adhere to the Effective Dart style guide.

Comment on lines +1472 to +1476
kFilenameExcedRange =>
'${message != null ? "$message. " : ""}The filename or extension is too long.\n'
'$e\n'
'Please consider moving the Flutter SDK and/or project to a shorter path, '
'or enabling long paths on Windows.',

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.

medium

According to the Dart style guide (Effective Dart: Style), single quotes are preferred for string literals. Using single quotes inside the string interpolation is more consistent with the rest of the codebase.

Suggested change
kFilenameExcedRange =>
'${message != null ? "$message. " : ""}The filename or extension is too long.\n'
'$e\n'
'Please consider moving the Flutter SDK and/or project to a shorter path, '
'or enabling long paths on Windows.',
kFilenameExcedRange =>
'${message != null ? '$message. ' : ''}The filename or extension is too long.\n'
'$e\n'
'Please consider moving the Flutter SDK and/or project to a shorter path, '
'or enabling long paths on Windows.',
References
  1. Effective Dart: Style recommends preferring single quotes for string literals. (link)

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 26, 2026
@auto-submit
auto-submit Bot merged commit 8d765b9 into flutter:flutter-3.47-candidate.0 Oct 26, 2026
12 checks passed
auto-submit Bot pushed a commit that referenced this pull request Oct 29, 2026
Adds CHANGELOG.md entries for the 3.47.9 stable hotfix (#195073, #194959, #195015). CI-only cherry-picks are omitted.

Tracker: #195427

### Edits to cherry-pick changelog descriptions
- #195073 and #195015: used verbatim from the cherry-pick PR's "Changelog Description".
- #194959 (@bkonyi): **edited** to follow [Hotfix Documentation Best Practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) (describe the state prior to the fix):
  - Original: "When running `flutter test` in pub workspaces, monorepos, or symlinked directories, fix a StateError crash during native assets compilation by falling back to appName matching."
  - Changelog: "When running `flutter test` in pub workspaces, monorepos, or symlinked directories on any platform, native assets compilation crashed with a `StateError`."
  - Changes: rewrote as the pre-fix behavior, added "on any platform", dropped the implementation detail ("falling back to appName matching").

@bkonyi FYI — please let us know if the edited wording for #194959 looks right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants