Skip to content

os.dart: Switch the codepage to UTF-8 when calling where.exe#186580

Open
CrossVR wants to merge 2 commits into
flutter:masterfrom
CrossVR:patch-1
Open

os.dart: Switch the codepage to UTF-8 when calling where.exe#186580
CrossVR wants to merge 2 commits into
flutter:masterfrom
CrossVR:patch-1

Conversation

@CrossVR
Copy link
Copy Markdown

@CrossVR CrossVR commented May 15, 2026

Currently the output of where on Windows is decoded using the system default code page queried through GetACP(). However, since where expects to be run from a console it uses the console output code page.

On a standard windows configuration these two code pages are different and one cannot be safely interpreted as the other. For example, in a U.S. locale this would cause the console code page 437 to be interpreted as code page 1252.

By prefixing the where command with chcp 65001 we can ensure UTF-8 encoding is being used resolving the conflict and forcing an encoding that is much safer for filesystem paths.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Currently the output of `where` on Windows is decoded using the system default code page queried through `GetACP()`. However, since `where` expects to be run from a console it uses the console output code page.

On a standard windows configuration these two code pages are different and one cannot be safely interpreted as the other. For example, in a U.S. locale this would cause the console code page 437 to be interpreted as code page 1252.

By prefixing the `where` command with `chcp 65001` we can ensure UTF-8 encoding is being used resolving the conflict and forcing an encoding that is much safer for filesystem paths.
@flutter-dashboard
Copy link
Copy Markdown

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.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 15, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 15, 2026
Copy link
Copy Markdown
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 updates the Windows executable search logic in packages/flutter_tools/lib/src/base/os.dart to set the active code page to UTF-8 before running the where command. A review comment points out that the use of the && operator requires setting runInShell: true to avoid execution failure and recommends redirecting the chcp output to nul to prevent it from interfering with the parsed results.

Comment thread packages/flutter_tools/lib/src/base/os.dart Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant