-
Notifications
You must be signed in to change notification settings - Fork 340
Custom commands to obtain the Dart/Flutter SDK path #5377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom commands to obtain the Dart/Flutter SDK path #5377
Conversation
|
Thanks for the PR! I thought I had replied on #5334 about this, but I can't see anything there now. If we are to support this, we need to be very explicit with what the expectations of the command output are, and handle all the possible failure cases (non-path output, error codes, failure to spawn the command) well (with tests). For example:
What's also not clear to me is how big this problem is in practice. We already look in the |
Which example would do that? Regarding the package_config.json inference, yes that's currently what we are relying on, but it's only working for Flutter projects. We have several projects in Dart where the version management is really cumbersome, especially when switching branches. The package_config.json unfortunately also requires the user to pub get and reload the vscode window so that the extension works properly. If you are interested with the idea I'm open to create tests for this, although I would appreciate some guidance on similar tests. I'm not familiar with testing vscode extensions. |
I'm on Windows so I'm not certain it's a fair comparison, but if I run Whereas the desired path would be "D:\Dev\Google\Flutter\Flutter main" (although we also tolerate the trailing
Ah, that makes more sense, thank you for the extra context :-)
If we can make the descriptions on the settings more explicit (what the expected output is, what happens if the command fails, error codes, non-path output) I am happy to accept this. I don't know how simple creating the tests will be, but I'd be happy to create at least some basic tests that could be used as a template to add more coverage (for things like errors, or multiple paths in the output like my Thanks! |
|
Oh, note that the example is using Great! In that case I'll write more in the description of the command. A few questions on decisions I took with the implementation:
|
Yep, I think if the command fails to produce a single path in any case, we should log this as a warning (there's an existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Sorry for the delay!)
One question, but otherwise looks reasonable to me.
I'll take a look at a way to test this shortly.
DanTup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for for the contribution!
Testing the full SDK search is going to be tricky, but in the meantime I think we can just test the runCustomGetSDKCommand command, since the return value is just going into existing code. I have some working tests locally that I'll land after this PR.
|
Adding some tests in #5395, will merge if/when they're all green. |
|
Great, thank you! |
|
@davidmartos96 I published a pre-release extension that included this change if you'd like to try it out before it ships in a stable release (despite the name, the pre-release versions of the extension should be pretty stable - I just push them a little in advance of stable releases to get some additional coverage before everyone gets them): The version number that contains this change is 3.103.20250121. |
|
Thank you, we will try it out with our projects |

Fixes #5334 and #5117
Adds 2 configurations, "getDartSdkCommand" and "getFlutterSdkCommand".
Here are a few examples on how can it be used: