Repository navigation
[flutter_tools] Pass relative archive paths to pub cache preload - #195077
Merged
auto-submit[bot] merged 2 commits intoOct 23, 2026
Merged
Conversation
In `_DefaultPub._preloadPubCache`, `flutter_tools` previously passed the full path of every `.tar.gz` archive in `$FLUTTER_ROOT/.pub-preload-cache` to a single `dart pub cache preload` command. On Windows, when `FLUTTER_ROOT` is located in a deeply nested directory (~145+ characters), repeating the full archive path for all ~170 preloaded archives causes the command line to exceed Windows' `CreateProcessW` 32,767-character limit and fail with OS error code `206` (`ERROR_FILENAME_EXCED_RANGE`: `The filename or extension is too long`). Run `dart pub cache preload` with `workingDirectory: preloadCacheDir.path` and pass only the archive basenames via `_fileSystem.path.basename` so the command line remains well below the Windows command-line length limit. ### Previous output ```text Flutter failed to run "C:\Users\User\AppData\Local\Temp\...\bin\cache\dart-sdk\bin\dart pub --suppress-analytics cache preload C:\Users\User\AppData\Local\Temp\...\.pub-preload-cache\...". The filename or extension is too long. ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... ``` ### Current output ```text Installed a.tar.gz in cache as a 1.0.0. Installed b.tar.gz in cache as b 1.0.0. ``` Fixes flutter#194570
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the pub preload cache mechanism to use relative paths instead of absolute paths for archive files, which prevents exceeding the Windows command line length limit when FLUTTER_ROOT is deeply nested. It also updates the corresponding tests to verify this behavior. Feedback suggests guarding the preload command execution with a check to ensure cacheFiles is not empty, avoiding unnecessary process execution when no archive files are present.
srawlins
approved these changes
Oct 22, 2026
This was referenced Oct 24, 2026
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
…tter#195077) In `_DefaultPub._preloadPubCache`, `flutter_tools` previously passed the full path of every `.tar.gz` archive in `$FLUTTER_ROOT/.pub-preload-cache` to a single `dart pub cache preload` command. On Windows, when `FLUTTER_ROOT` is located in a deeply nested directory (~145+ characters), repeating the full archive path for all ~170 preloaded archives causes the command line to exceed Windows' `CreateProcessW` 32,767-character limit and fail with OS error code `206` (`ERROR_FILENAME_EXCED_RANGE`: `The filename or extension is too long`). Run `dart pub cache preload` with `workingDirectory: preloadCacheDir.path` and pass only the archive basenames via `_fileSystem.path.basename` so the command line remains well below the Windows command-line length limit, and skip invoking `dart pub cache preload` if no `.tar.gz` archives are present in `.pub-preload-cache`. ### Previous output ```text Flutter failed to run "C:\Users\User\AppData\Local\Temp\...\bin\cache\dart-sdk\bin\dart pub --suppress-analytics cache preload C:\Users\User\AppData\Local\Temp\...\.pub-preload-cache\...". The filename or extension is too long. ProcessException: The filename or extension is too long Command: C:\Users\User\AppData\Local\Temp\... ``` ### Current output ```text Installed a.tar.gz in cache as a 1.0.0. Installed b.tar.gz in cache as b 1.0.0. ``` Fixes flutter#194570
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
_DefaultPub._preloadPubCache,flutter_toolspreviously passed the full path of every.tar.gzarchive in$FLUTTER_ROOT/.pub-preload-cacheto a singledart pub cache preloadcommand. On Windows, whenFLUTTER_ROOTis located in a deeply nested directory (~145+ characters), repeating the full archive path for all ~170 preloaded archives causes the command line to exceed Windows'CreateProcessW32,767-character limit and fail with OS error code206(ERROR_FILENAME_EXCED_RANGE:The filename or extension is too long).Run
dart pub cache preloadwithworkingDirectory: preloadCacheDir.pathand pass only the archive basenames via_fileSystem.path.basenameso the command line remains well below the Windows command-line length limit, and skip invokingdart pub cache preloadif no.tar.gzarchives are present in.pub-preload-cache.Previous output
Current output
Fixes #194570