Skip to content

[flutter_tools] Fix flutter doctor path validation for symlinked SDKs - #191975

Closed
SSJ-ZYJ wants to merge 2 commits into
flutter:masterfrom
SSJ-ZYJ:master
Closed

SSJ-ZYJ wants to merge 2 commits into
flutter:masterfrom
SSJ-ZYJ:master

Conversation

@SSJ-ZYJ

@SSJ-ZYJ SSJ-ZYJ commented Aug 28, 2026

Copy link
Copy Markdown

Description

Flutter's FlutterValidator resolves the executable found on PATH, but previously compared that resolved path with the unresolved Flutter SDK root.

On Windows, package managers such as Scoop expose the active SDK through a current Junction:

current\bin\flutter -> 3.47.2\bin\flutter

Both paths refer to the same SDK, but flutter doctor incorrectly reported Flutter and Dart as being outside the current SDK.

This change:

  • Resolves the Flutter SDK root directory only for internal containment comparison.
  • Preserves the logical SDK root for version information, warnings, and PATH suggestions.
  • Catches FileSystemException when the root cannot be resolved and falls back to the existing lexical comparison.
  • Preserves the existing case normalization, separator normalization, and separator-boundary checks.
  • Does not modify Cache.flutterRoot, public APIs, or user-visible logical paths.

No screenshots are applicable because this change affects Flutter CLI validation output.

Issues Fixed

Fixes #191936

Testing

  • flutter test --no-pub test/general.shard/flutter_validator_test.dart from packages/flutter_tools — 23 tests passed.
  • flutter analyze from packages/flutter_tools — passed.
  • dart format --output=none --set-exit-if-changed — passed.
  • Verified with a Windows Scoop Junction using where.exe flutter, where.exe dart, and the patched doctor -v.
  • Confirmed that both Flutter and Dart PATH warnings disappear while the other doctor checks remain unchanged.

The regression tests cover:

  • Flutter and Dart binaries under a Windows-style directory link.
  • Unrelated SDK paths, which must continue to produce warnings.
  • SDK roots that cannot be resolved.
  • Existing Windows case and separator behavior.

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.

@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 FlutterValidator to resolve symbolic links for the Flutter SDK root directory before checking if the resolved Flutter binary path is within it, falling back to the unresolved path if a FileSystemException occurs. It also adds tests to verify this behavior with symlinked SDKs on Windows and to ensure the validator handles unresolved SDK roots gracefully. There are no review comments, and I have no feedback to provide.

@bkonyi

bkonyi commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Hi there!

Thanks for your contribution! However, this issue has been resolved on master, so I'm going to close this PR.

@bkonyi bkonyi closed this Sep 24, 2026
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.

flutter doctor incorrectly warns that Flutter/Dart are outside the SDK when installed via a Scoop junction on Windows

2 participants