You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create doc page that describes all possible ways to set path to flutter. #4665
Now, when there are so many ways to set SDK in VSCode, including hidden way to build project and thus set flutter path to what was used for the build, a page that describes all of them and their priorities for VSCode, would really help.
There are a lot of places that we look for SDKs, but this is mostly because we want to do our best to find the SDK. I'm not sure we should document them all as ways you can set the SDK, because really users should only ever directly a) add an SDK to PATH or b) use the dart.sdkPath/dart.flutterSdkPath settings. I don't think we should guide them towards anything else, however I do think we should make it easier to understand how we found the SDK we're using.
Perhaps we should add a command that can provide information about how the current SDK was located, such as a "Doctor" command. It could detail the SDK search including where it looked, and which paths were discounted because they were not valid.
For example:
Workspace contains Flutter project, searching for a Flutter SDK:
- Workspace settings Not Found
- User settings Invalid C:\Deleted-Flutter-SDK\ (folder does not exist)
- Project package_config.json Found C:\Flutter\SDK used by C:\MyProject\.dart_tool\package_config.json
- Project ./.flutter Not Found
- Project ./vendor/flutter Found C:\MyProject\vendor\flutter
- FLUTTER_ROOT environment variable Invalid C:\Broken-Flutter-SDK\ (does not contain a bin\flutter file)
- Snap (~/snap/flutter/common/flutter) Not Found
- ~/flutter-sdk Not Found
- /google/flutter Not Found
- PATH environment variable Found C:\Flutter\SDK
Using first valid SDK C:\Flutter\SDK found via Project package_config.json.
There's already support for switching of SDKs here and it works with both Dart and Flutter (and doesn't require installing additional tools). It's been a while since I looked at it, but I believe fvm requires (or required) running everything through it (fvm flutter run) and since we spawn lots of the SDK tools for different purposes, having to plumb all that through didn't seem worth it (I'm not really sure what benefit there would be over what we already have).
(We also need to locate files inside the SDK, so we need to know the path, not just that we can run fvm to get the right version)
Looks like FVM already has docs for working with VS Code's built-in switcher at https://fvm.app/docs/getting_started/configuration/#vs-code (for both detecting the current SDK, and using the switcher to switch between FVM versions). I don't use it so I don't know if there are things that don't work this way though.
I'm open to improving support for other version managers if there's demand, but I'd rather do that in ways that are open to all version managers and don't require specific coding for individual apps because it's not very scalable to build them all in (for ex. https://puro.dev/ is another popular one).
Activity
DanTup commentedon Jul 27, 2023
There are a lot of places that we look for SDKs, but this is mostly because we want to do our best to find the SDK. I'm not sure we should document them all as ways you can set the SDK, because really users should only ever directly a) add an SDK to PATH or b) use the
dart.sdkPath/dart.flutterSdkPathsettings. I don't think we should guide them towards anything else, however I do think we should make it easier to understand how we found the SDK we're using.Perhaps we should add a command that can provide information about how the current SDK was located, such as a "Doctor" command. It could detail the SDK search including where it looked, and which paths were discounted because they were not valid.
For example:
incendial commentedon Jul 27, 2023
@DanTup you don't have first-class support for fvm, why?
DanTup commentedon Jul 27, 2023
There's already support for switching of SDKs here and it works with both Dart and Flutter (and doesn't require installing additional tools). It's been a while since I looked at it, but I believe fvm requires (or required) running everything through it (
fvm flutter run) and since we spawn lots of the SDK tools for different purposes, having to plumb all that through didn't seem worth it (I'm not really sure what benefit there would be over what we already have).(We also need to locate files inside the SDK, so we need to know the path, not just that we can run
fvmto get the right version)incendial commentedon Jul 28, 2023
Interesting, was not aware of that.
This one is doable, I supported both fvm and fvm default in DCM.
DanTup commentedon Jul 31, 2023
Looks like FVM already has docs for working with VS Code's built-in switcher at https://fvm.app/docs/getting_started/configuration/#vs-code (for both detecting the current SDK, and using the switcher to switch between FVM versions). I don't use it so I don't know if there are things that don't work this way though.
I'm open to improving support for other version managers if there's demand, but I'd rather do that in ways that are open to all version managers and don't require specific coding for individual apps because it's not very scalable to build them all in (for ex. https://puro.dev/ is another popular one).
DanTup commentedon Oct 21, 2024
I added a new page here:
https://dartcode.org/docs/sdk-locating/
Add more docs about SDK location rules