Skip to content

[flutter_tools] Pass relative archive paths to pub cache preload - #195077

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:pub-preload-relative-paths
Oct 23, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:pub-preload-relative-paths

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Installed a.tar.gz in cache as a 1.0.0.
Installed b.tar.gz in cache as b 1.0.0.

Fixes #194570

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
@bkonyi bkonyi added the CICD Run CI/CD label Oct 22, 2026
@bkonyi
bkonyi marked this pull request as ready for review October 22, 2026 15:55
@bkonyi
bkonyi requested a review from srawlins October 22, 2026 15:56

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

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 22, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 23, 2026
Merged via the queue into flutter:master with commit 3e1bd8f Oct 23, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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

2 participants