Allow flutter SDK binary to be a symlink - #9924
Open
johnpryan wants to merge 7 commits into
Open
Conversation
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`.
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran
dt update-flutter-sdk --update-on-path, butFlutterSdk.findFromPathEnvironmentVariablefailed because theflutteron my PATH was a symlink (e.g./usr/local/bin/flutter). It strippedbin/flutterfrom the unresolved symlink path, resulting in/usr/localbeing treated as the SDK root directory.This change:
FlutterSdk.findFromPathto resolve symbolic links before determining the SDK root directory.tool/test/model_test.dartforFlutterSdk.findFromPath.(The reason I use symlinks is due to dart-lang/ai#503)