Skip to content

Allow flutter SDK binary to be a symlink - #9924

Open
johnpryan wants to merge 7 commits into
flutter:masterfrom
johnpryan:resolve-flutter-sdk-symlink
Open

Allow flutter SDK binary to be a symlink#9924
johnpryan wants to merge 7 commits into
flutter:masterfrom
johnpryan:resolve-flutter-sdk-symlink

Conversation

@johnpryan

@johnpryan johnpryan commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

I randt update-flutter-sdk --update-on-path, but FlutterSdk.findFromPathEnvironmentVariable failed because theflutter on my PATH was a symlink (e.g. /usr/local/bin/flutter). It stripped bin/flutter from the unresolved symlink path, resulting in /usr/local being treated as the SDK root directory.

This change:

  • Updates FlutterSdk.findFromPath to resolve symbolic links before determining the SDK root directory.
  • Adds unit tests in tool/test/model_test.dart for FlutterSdk.findFromPath.

(The reason I use symlinks is due to dart-lang/ai#503)

When running `dt update-flutter-sdk --update-on-path`, `FlutterSdk.findFromPathEnvironmentVariable` failed if `flutter` on PATH was a symlink (e.g. `/usr/local/bin/flutter`). It stripped `bin/flutter` from the unresolved symlink path, resulting in `/usr/local` being treated as the SDK root directory.

This change:
- Updates `FlutterSdk.findFromPath` to resolve symbolic links before determining the SDK root directory.
- Updates `UpdateFlutterSdkCommand` to use the remote returned by `findRemote` instead of hardcoding 'upstream'.
- Adds unit tests in `tool/test/model_test.dart` for `FlutterSdk.findFromPath`.

@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 improves Flutter SDK path resolution in FlutterSdk.findFromPath by resolving symbolic links and handling different input path formats (executable, bin directory, or SDK root). It also updates locateTheFlutterSdk to use this new logic, refactors a remote-finding print statement, and adds unit tests covering these path resolution scenarios. Feedback suggests simplifying the symbolic link resolution logic and improving its robustness by replacing redundant existence checks with a try-catch block to handle potential FileSystemException errors.

Comment thread tool/lib/model.dart
@johnpryan
johnpryan requested a review from a team as a code owner July 28, 2026 20:56
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.

1 participant