Dart-Code: Flutter: Change SDK does not detect multiple SDKs

Describe the bug When there are multiple Flutter SDKs installed, the VSCode extension does not correctly identify them:

In my particular case, I have two installations:

  • ~Development/github.com/flutter/flutter/bin/flutter
  • ~Development/github.com/shorebirdtech/_shorebird/shorebird/bin/shorebird/cache/flutter/bin/flutter

The VSCode extension only detects the latter even though my PATH contains the former:

Run from within VSCode’s integrated terminal:

echo $PATH
/Users/felix/Desktop/sage/bin:/opt/homebrew/opt/openssl@3/bin:/Users/felix/Downloads/google-cloud-sdk/bin:/Users/felix/.nvm/versions/node/v18.15.0/bin:/Applications/Postgres.app/Contents/Versions/14/bin:/Users/felix/Library/Android/sdk/platform-tools:/Users/felix/Library/Android/sdk/tools:/Users/felix/Development/github.com/chromium/depot_tools:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/felix/Desktop/sage/bin:/opt/homebrew/opt/openssl@3/bin:/Users/felix/Downloads/google-cloud-sdk/bin:/Users/felix/.nvm/versions/node/v18.15.0/bin:/Applications/Postgres.app/Contents/Versions/14/bin:/Users/felix/Library/Android/sdk/platform-tools:/Users/felix/Library/Android/sdk/tools:/Users/felix/Development/github.com/chromium/depot_tools:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/felix/.cargo/bin:/Users/felix/Development/github.com/flutter/flutter/bin:/Users/felix/fvm/default/bin/cache/dart-sdk/bin:/Users/felix/.pub-cache/bin:/Users/felix/Development/github.com/shorebirdtech/_shorebird/shorebird/bin:/Users/felix/Development/github.com/flutter/flutter/bin:/Users/felix/fvm/default/bin/cache/dart-sdk/bin:/Users/felix/.pub-cache/bin:/Users/felix/Development/github.com/shorebirdtech/_shorebird/shorebird/bin

Run from Mac terminal:

/Users/felix/.shorebird/bin:/Users/felix/Desktop/sage/bin:/opt/homebrew/opt/openssl@3/bin:/Users/felix/Downloads/google-cloud-sdk/bin:/Users/felix/.nvm/versions/node/v18.15.0/bin:/Applications/Postgres.app/Contents/Versions/14/bin:/Users/felix/Library/Android/sdk/platform-tools:/Users/felix/Library/Android/sdk/tools:/Users/felix/Development/github.com/chromium/depot_tools:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/felix/.cargo/bin:/Users/felix/Development/github.com/flutter/flutter/bin:/Users/felix/fvm/default/bin/cache/dart-sdk/bin:/Users/felix/.pub-cache/bin:/Users/felix/Development/github.com/shorebirdtech/_shorebird/shorebird/bin

Screenshot 2023-06-22 at 2 19 50 PM

I have disabled the setting to update the PATH:

Screenshot 2023-06-22 at 2 23 59 PM

When I override the SDK path in my user settings.json it still does not appear to have any effect:

Screenshot 2023-06-22 at 2 25 45 PM

The only way I’m able to work around this is to move the original installation to a different path, relaunch vscode, and revert the rename.

To Reproduce Steps to reproduce the behavior:

  1. Install multiple Flutter SDKs in different locations
  2. Open the VSCode command palette and run the Flutter: Change SDK command
  3. Note that only one of the two installation paths is detected and there is no way to change it.

Expected behavior I expect to be able to configure the SDK paths

Please complete the following information:

  • Operating System and version: MacOS v13.0
  • VS Code version:
Version: 1.79.1 (Universal)
Commit: 4cb974a7aed77a74c7813bdccd99ee0d04901215
Date: 2023-06-12T16:16:49.215Z (1 wk ago)
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.1.0
  • Dart extension version: v3.66.0
  • Dart/Flutter SDK version: Flutter 3.10.5 and Dart 3.0.5

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 23 (10 by maintainers)

Most upvoted comments

After troubleshooting it appears the “dart.flutterSdkPath” expects path to the Flutter directory not bin/flutter. Thanks @DanTup 🙏

it takes the first sdk, i.e, .shorebird because it exists in the home dir.

We don’t look in (many) arbitrary folders in the homedir - are you sure it’s not selecting this one because it’s on PATH, or because it’s referenced in .dart_tool/package_config.json?

If you think it’s making the wrong (or at least sub-optimal) decision and can provide an explanation of why it should select a different one, do file an issue and we can try to tweak the rules. Ideally we’d select the best SDK in all cases and you’d never need to use the setting unless you want to specifically override for that project - in practice it’s tricky to get to that though 😃

after explicitly setting my Flutter SDK path to /Users/bryanoltman/Documents/flutter/bin/flutter

You shouldn’t have bin/flutter on the end, these are paths to the SDKs, not to the binaries.

that is the only one I see in VS Code’s Flutter: Change SDK menu.

If that’s the only SDK in the dart.flutterSdkPaths setting, then it’s expected that’s the only one that shows up here. The Change SDK commands only ever looks at dart.flutterSdkPaths. It searches the locations you’ve listed here for SDKs, and then shows a picklist of them. If any of them happen to match the current SDK being used, it will mark them as such - but it won’t list anything not in this setting.

That setting is only really useful if you have multiple SDKs you want to switch between. Otherwise, you just want to set the singular dart.flutterSdkPath setting.