Repository navigation
Conversation
…h PowerShell fallback" Relands flutter#192298 (reverted in flutter#193161 due to flutter#193156). Resolve Windows System32 tar.exe explicitly via SystemRoot/windir environment variables instead of relying on bare tar on PATH, preventing GNU tar from Git for Windows or MSYS2 from being invoked.
Contributor
There was a problem hiding this comment.
Code Review
This pull request replaces the Dart-based archive package with native Windows utilities (tar.exe or PowerShell) for unzipping and unpacking archives on Windows, updating the corresponding error handling and tests. The review feedback highlights a potential resource leak where the temporary directory created during prebuilt Windows app extraction is not cleaned up if the extraction process fails with an exception or a ToolExit.
mattkae
reviewed
Nov 12, 2026
mattkae
left a comment
Contributor
There was a problem hiding this comment.
Testing + commenting feedback!
Explain why `_WindowsUtils._tarPath` prefers `SYSTEMROOT` over `WINDIR` before falling back to `C:\Windows`, drop duplicate mixed-case environment lookups since `Platform.environment` is case-insensitive on Windows, and test all three resolution paths in `os_test.dart`.
loic-sharma
reviewed
Nov 12, 2026
loic-sharma
reviewed
Nov 12, 2026
loic-sharma
reviewed
Nov 12, 2026
loic-sharma
reviewed
Nov 12, 2026
loic-sharma
reviewed
Nov 12, 2026
Remove the PowerShell `Expand-Archive` fallback from `_WindowsUtils.unzip` so both `unzip` and `unpack` extract archives via `%SYSTEMROOT%\System32\tar.exe` (`bsdtar`, included since Windows 10 version 1803), avoiding inbox Windows PowerShell 5.1 `Expand-Archive` path-traversal gaps. Extract `tarResolutionCases` in `os_test.dart`, add explicit tests verifying `-P` and `--absolute-paths` are never passed to `tar.exe`, drop the redundant `FileSystemException` catch in `WindowsApp.fromPrebuiltApp`, and add cross-platform `OperatingSystemUtils` archive extraction and zip-slip tests in `os_utils_test.dart`.
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.
Relands #192298 (reverted in #193161 due to #193156).
Fix for #193156
In #192298,
_WindowsUtils.unzipand_WindowsUtils.unpackchecked_processManager.canRun('tar')and invoked baretar. On Windows environments where Git for Windows (usr\bin) or MSYS2 is placed ahead ofC:\Windows\System32onPATH(such asflutter/packagesandflutter/devtoolsCI bots running under Git Bash), baretarresolved to MSYS2 GNUtar(/usr/bin/tar) instead of Windows' built-inbsdtar(C:\Windows\System32\tar.exe). GNUtarinterprets Windows drive letters (C:\...) as remote hostnames (Cannot connect to C: resolve failed) and does not support.ziparchives.This reland resolves Windows' built-in
bsdtarexplicitly via%SYSTEMROOT%\System32\tar.exe(falling back to%WINDIR%andC:\Windows) so GNUtaronPATHis never invoked.Validation (
ledagainstflutter/packagesWindows Roll Builders)Verified manually via
ledby overriding theflutter/fluttercheckout torefs/pull/193515/headon the previously failingflutter/packagesWindows builders:Windows_x64 windows-build_all_packages master(8669301311576632273): PASSED (extracted all four Windows SDK.ziparchives insidebash.exeand built theall_packagesWindows debug and release apps).Windows_x64 custom_package_tests master - packages(8669300947865231921): PASSED (tested against roll PR flutter/packages#12973, exercisingpackages/pigeonwindows_unittests, extracting the Windows SDK and buildingtest_plugin_example.exe).Summary of Changes
package:archive(ZipDecoderandTarDecoder) decoding in_WindowsUtils.unzipand_WindowsUtils.unpackwith native%SYSTEMROOT%\System32\tar.exe -xf <file> -C <target>, streaming directly on disk to prevent out-of-memory crashes on large archives (#133371) and removingpackage:archivefromos.dartandwindows/application_package.dart(#115660, wherepackage:archive4.x pulls inpackage:posixFFI).System32\tar.exe(bsdtar, included since Windows 10 version 1803 / build 17063) for bothunzipandunpackwithout a PowerShellExpand-Archivefallback (inbox Windows PowerShell 5.1Microsoft.PowerShell.Archive1.0.1.0lacks zip-slip path-traversal validation).bsdtarstrips leading slashes/drive letters and rejects archive entries containing..components unless-P(--absolute-paths) is passed.ProcessExceptioninWindowsApp.fromPrebuiltApp(allowingToolExitto propagate) to log'Invalid prebuilt Windows app. Unable to extract from archive.'.os_test.dartandapplication_package_test.dartplus cross-platform real extraction and zip-slip tests inos_utils_test.dart.Fixes #193156
Fixes #133371
Part of #115660
Pre-launch Checklist
///).