Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Oct 9, 2024

Powershell v6+ use the executable name pwsh.exe instead of powershell.exe. This change adds support for determining the Windows version on systems that solely use pwsh.exe and don't have powershell.exe on the PATH.

Fixes #156189.

@bkonyi bkonyi requested a review from andrewkolos October 9, 2024 14:58
@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop labels Oct 9, 2024
Copy link
Contributor

@andrewkolos andrewkolos left a comment

Choose a reason for hiding this comment

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

LGTM with nits

Comment on lines 111 to 116
const List<String> psArgs = <String>['-command', argument];
try {
return await processManager.run(<String>['powershell', ...psArgs]);
} on ProcessPackageExecutableNotFoundException {
return processManager.run(<String>['pwsh', ...psArgs]);
}
Copy link
Contributor

@andrewkolos andrewkolos Oct 9, 2024

Choose a reason for hiding this comment

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

This LGTM as-is, but I think there is a world where we can detect that powershell is unavailable (via ProcessManager.canRun) and then make the validator fail with a ValidationResult.missing that has a more specific message rather than throwing an exception on relying on higher-level error handling. (This is just an FYI; my hope is that this knowledge is useful for future work on validators).

However, this kind of situation is unlikely to happen again very often, and the error message generated in that case is still sufficient to figure out what's going wrong here1—hence the LGTM.

Footnotes

  1. This is evidenced by the reporting user being able to figure out what was going wrong here themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great point! I definitely just skipped past all the validation logic at the top of the file... :)

I've gone ahead and added a validation step and made more use of ProcessManager.canRun rather than attempting to run executables to determine whether or not they exist.

fail('Should have thrown, but successfully ran ${result.stdout}');
} on ProcessPackageExecutableNotFoundException {
// Expected
// ignore: avoid_catches_without_on_clauses
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line necessary? flutter analyze passes without it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then again, the Linux analyze check is failing; so me running flutter analyze locally is apparently not sufficient 🤪

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we seem to have avoid_catches_without_on_clauses: true as an override in the tool's analysis_options.yaml, so the analysis server was complaining about it locally. Very annoying that it apparently doesn't pick up the same set of lints as the bots though...

@andrewkolos andrewkolos self-requested a review October 10, 2024 17:52
…or.dart

Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
@andrewkolos
Copy link
Contributor

LGTM

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 10, 2024

auto label is removed for flutter/flutter/156476, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@bkonyi bkonyi merged commit ad370c8 into master Oct 15, 2024
@bkonyi bkonyi deleted the fix_issue_156189 branch October 15, 2024 15:48
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProcessException: Failed to find "powershell" in the search path. Command: powershell

2 participants