Skip to content

Conversation

@aam
Copy link
Member

@aam aam commented Sep 24, 2025

With modern pwsh.exe there seems to be a problem with call operator making nested powershell script invocation. Use Invoke-Expression instead.

Fixes #173554

@aam aam requested a review from jtmcdole as a code owner September 24, 2025 16:34
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link
Contributor

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

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 changes how a nested PowerShell script is called in update_engine_version.ps1, switching from the call operator (&) to Invoke-Expression to resolve an issue with modern pwsh.exe. However, the current implementation is not robust and will fail if the Flutter SDK path contains spaces. My review provides a critical comment with a code suggestion to fix this by ensuring the path is correctly quoted for Invoke-Expression, thus supporting paths with spaces.

# engine artifacts built from CI.
} else {
$engineVersion = & "$flutterRoot/bin/internal/content_aware_hash.ps1"
$engineVersion = Invoke-Expression "$flutterRoot/bin/internal/content_aware_hash.ps1"
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Using Invoke-Expression directly on a path string is unsafe if the path contains spaces. If $flutterRoot has a space, Invoke-Expression will misinterpret the path, causing the command to fail. The original use of the call operator (&) with a quoted path correctly handles spaces.

To ensure your fix for pwsh.exe also works for paths with spaces, you should include the call operator (&) and quotes inside the string that Invoke-Expression executes. This will ensure the path is treated as a single, complete argument.

  $engineVersion = Invoke-Expression "& '$flutterRoot/bin/internal/content_aware_hash.ps1'"

@jtmcdole
Copy link
Member

Today we say we support Powershell 5.1 - which ships default on windows. pwsh is the latest version ~7+

Our testing infra I think is correctly finding a problem here. We should make sure the PR works for both environments of powershell.

Invoke-Expression : The term 'C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the 
path is correct and try again.
At C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter sdk\bin\internal\update_engine_version.ps1:60 char:20
+ ... neVersion = Invoke-Expression "$flutterRoot/bin/internal/content_awar ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter:String) [Invoke-Expression], Com 
   mandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand

@aam
Copy link
Member Author

aam commented Sep 24, 2025

Today we say we support Powershell 5.1 - which ships default on windows. pwsh is the latest version ~7+

Our testing infra I think is correctly finding a problem here. We should make sure the PR works for both environments of powershell.

Locally forcing powershell.exe, rather than pwsh.exe(via commenting out powershell_executable logic in flutter.bat) flow seems to work fine. Why do you think the failure on the bots is related to powershell 5 vs 7 versions?

Invoke-Expression : The term 'C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the 
path is correct and try again.
At C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter sdk\bin\internal\update_engine_version.ps1:60 char:20
+ ... neVersion = Invoke-Expression "$flutterRoot/bin/internal/content_awar ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\b\s\w\ir\x\w\rc\tmp22nzoqt0\flutter:String) [Invoke-Expression], Com 
   mandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand

gemini-code-assist code review was very helpful as it pointed out that quoting filename is important to handle spaces in file name properly.

@aam aam requested a review from jason-simmons September 25, 2025 15:16
@jtmcdole
Copy link
Member

Looks like this is now passing.

@aam aam added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 29, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 29, 2025
Merged via the queue into flutter:master with commit 10359a0 Sep 29, 2025
155 of 156 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 1, 2025
…10145)

Manual roll requested by [email protected]

flutter/flutter@96fe3b3...c9608e2

2025-09-30 [email protected] Implement framework interface for the dialog window archetype (flutter/flutter#176202)
2025-09-30 [email protected] Update flutter test to use SemanticsFlags (flutter/flutter#175987)
2025-09-30 [email protected] Set minimum supported java version to 17  (flutter/flutter#176226)
2025-09-30 [email protected] Reduce timeout for Linux web_tool_tests back to 60 (flutter/flutter#176286)
2025-09-30 [email protected] Roll Packages from 34eec78 to 287739d (9 revisions) (flutter/flutter#176284)
2025-09-30 [email protected] [web] Bump Firefox to 143.0 (flutter/flutter#176110)
2025-09-30 [email protected] Migrate to `WidgetStateBorderSide` (flutter/flutter#176164)
2025-09-30 [email protected] Enhance input decorator padding logic for character counter in text f… (flutter/flutter#175706)
2025-09-30 [email protected] Update the test package for the web engine unit test bits. (flutter/flutter#176241)
2025-09-30 [email protected] Warn if embedder API calls don't return success (flutter/flutter#176184)
2025-09-30 [email protected] Roll Fuchsia Test Scripts from APSBP-sS-3FX69Ihf... to JUeFbA8y0E-_pj-bg... (flutter/flutter#176243)
2025-09-30 [email protected] Roll GN to 81b24e01 (flutter/flutter#176119)
2025-09-29 [email protected] Rename DisplayMonitor to DisplayManager on Win32 (flutter/flutter#175619)
2025-09-29 [email protected] [Android] Use headingLevel for heading accessibility property (flutter/flutter#175416)
2025-09-29 [email protected] BUILD.gn: Support LTO build on Linux (flutter/flutter#176191)
2025-09-29 [email protected] fix `assertEquals` arguments are in wrong order in `FlutterJNITest.java` (flutter/flutter#175728)
2025-09-29 [email protected] Add tests for `Project` getters  (flutter/flutter#175994)
2025-09-29 [email protected] Roll Fuchsia Linux SDK from 8zjcJic_DtvB2Bo2x... to rcOl0yxJb4znJ903Y... (flutter/flutter#176215)
2025-09-29 [email protected] Clean up typos in `PlatformViewsControllerTest.java` (flutter/flutter#175725)
2025-09-29 [email protected] Migrate java 11 usage to java 17 usage for templates (flutter/flutter#176203)
2025-09-29 [email protected] User Invoke-Expression instead of call operator for nested Powershell scripts invocations (on Windows) (flutter/flutter#175941)
2025-09-29 [email protected] Update changelog as on 3.35 branch (flutter/flutter#176216)
2025-09-29 [email protected] fix typo in `Crashes.md` (flutter/flutter#175959)
2025-09-29 [email protected] Add scene plugin lifecycle events (flutter/flutter#175866)
2025-09-29 [email protected] Migrate tests and documentation to set java version to 17 (flutter/flutter#176204)
2025-09-29 [email protected] Update Engine CI to use NDK r28c  (flutter/flutter#175870)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah pushed a commit to okorohelijah/flutter that referenced this pull request Oct 7, 2025
… scripts invocations (on Windows) (flutter#175941)

With modern pwsh.exe there seems to be a problem with call operator
making nested powershell script invocation. Use Invoke-Expression
instead.

Fixes flutter#173554
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
… scripts invocations (on Windows) (flutter#175941)

With modern pwsh.exe there seems to be a problem with call operator
making nested powershell script invocation. Use Invoke-Expression
instead.

Fixes flutter#173554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Unable to determine engine version

2 participants