Skip to content

Flutter SDK installed via package managers like Hermit are not detected/initialized correctly #3961

@alecthomas

Description

@alecthomas

Describe the bug

The VSCode extensions are unable to find Flutter or Dart (see attached log below) if ./bin/dart or ./bin/flutter exist, even though FLUTTER_ROOT is set correctly. I would expect that with FLUTTER_ROOT explicitly set, it would be used by the extension. The flutter/dart command-line tools work perfectly FWIW.

Flutter is installed in /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0.
FLUTTER_ROOT is set export FLUTTER_ROOT=/Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0

I have a shell script wrapper around dart/flutter located in ~/Projects/flutter/bin (basically #!/bin/bash\nexec /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin/$cmd). On the command line this works perfectly (screenshot below), but the VSCode extension preferences the wrapper scripts over FLUTTER_ROOT, resulting in it being unable to find Dart or the Flutter SDK.

I understand that this is not a common setup, but we use a tool called Hermit for managing hermetic environments which uses wrapper scripts to bootstrap tools, including Flutter.

To Reproduce

Install Flutter SDK into some location. Set FLUTTER_ROOT to that location then:

mkdir -p ~/test/bin
cd ~/test
echo 'exec $FLUTTER_ROOT/bin/flutter "$@"' > bin/flutter
echo 'exec $FLUTTER_ROOT/bin/dart "$@"' > bin/dart
chmod +x bin/{flutter,dart}
export PATH="$PWD/bin:$PATH"

flutter doctor
flutter create .
flutter run

The above all works.

Next do the following:

code .

This results in the extension reinitialising and failing with:
image

Expected behavior

I would expect that with FLUTTER_ROOT explicitly set, it would be used by the extension.

Screenshots

Command line working fine:
image

Extension log section
[3:16:59 pm] [General] [Info] Searching for flutter
[3:16:59 pm] [General] [Info]     Looking for flutter in:
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin/
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/.flutter
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/.flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/vendor/flutter
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/vendor/flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:16:59 pm] [General] [Info]         /Users/aat/flutter-sdk
[3:16:59 pm] [General] [Info]         /Users/aat/flutter-sdk/bin
[3:16:59 pm] [General] [Info]         /google/flutter
[3:16:59 pm] [General] [Info]         /google/flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/bin
[3:16:59 pm] [General] [Info]         /opt/homebrew/bin
[3:16:59 pm] [General] [Info]         /opt/homebrew/bin
[3:16:59 pm] [General] [Info]         /opt/homebrew/sbin
[3:16:59 pm] [General] [Info]         /usr/local/bin
[3:16:59 pm] [General] [Info]         /usr/bin
[3:16:59 pm] [General] [Info]         /bin
[3:16:59 pm] [General] [Info]         /usr/sbin
[3:16:59 pm] [General] [Info]         /sbin
[3:16:59 pm] [General] [Info]         /opt/local/bin
[3:16:59 pm] [General] [Info]         /usr/local/munki
[3:16:59 pm] [General] [Info]         /usr/local/munki/bin
[3:16:59 pm] [General] [Info]         /Applications/kitty.app/Contents/MacOS
[3:16:59 pm] [General] [Info]         /Applications/kitty.app/Contents/MacOS/bin
[3:16:59 pm] [General] [Info]         /opt/homebrew/opt/fzf/bin
[3:16:59 pm] [General] [Info]     Found at:
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin/
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:16:59 pm] [General] [Info] Following symlink: /Users/aat/Projects/flutter/bin/flutter ==> /Users/aat/Projects/flutter/bin/hermit
[3:16:59 pm] [General] [Info] Following symlink: /Users/aat/Projects/flutter/bin/flutter ==> /Users/aat/Projects/flutter/bin/hermit
[3:16:59 pm] [General] [Info]     Candidate paths to be post-filtered:
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:16:59 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:16:59 pm] [General] [Info]         /Users/aat/Projects/flutter
[3:16:59 pm] [General] [Info]     Found at /Users/aat/Projects/flutter
[3:16:59 pm] [General] [Info]     Returning SDK path /Users/aat/Projects/flutter for flutter
[3:16:59 pm] [General] [Info] Flutter is not initialized, running 'flutter doctor' to force...
[3:16:59 pm] [General] [Info] (PROC 23519) Logging data for process...
[3:16:59 pm] [FlutterDaemon] [Info] Process /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin/flutter terminated! 0, null
[3:17:01 pm] [General] [Info] (PROC 23519) [✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm (Rosetta), locale en-AU)
[3:17:01 pm] [General] [Info] (PROC 23519)     • Flutter version 3.0.0 at /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:17:01 pm] [General] [Info] (PROC 23519)     • Upstream repository https://github.com/flutter/flutter.git
[3:17:01 pm] [General] [Info] (PROC 23519)     • Framework revision ee4e09cce0 (4 days ago), 2022-05-09 16:45:18 -0700
[3:17:01 pm] [General] [Info] (PROC 23519)     • Engine revision d1b9a6938a
[3:17:01 pm] [General] [Info] (PROC 23519)     • Dart version 2.17.0
[3:17:01 pm] [General] [Info] (PROC 23519)     • DevTools version 2.12.2
[3:17:01 pm] [General] [Info] (PROC 23519)
[3:17:01 pm] [General] [Info] (PROC 23519) [✗] Android toolchain - develop for Android devices
[3:17:01 pm] [General] [Info] (PROC 23519)     ✗ Unable to locate Android SDK.
[3:17:01 pm] [General] [Info] (PROC 23519)       Install Android Studio from: https://developer.android.com/studio/index.html
[3:17:01 pm] [General] [Info] (PROC 23519)       On first launch it will assist you in installing the Android SDK components.
[3:17:01 pm] [General] [Info] (PROC 23519)       (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[3:17:01 pm] [General] [Info] (PROC 23519)       If the Android SDK has been installed to a custom location, please use
[3:17:01 pm] [General] [Info] (PROC 23519)       `flutter config --android-sdk` to update to that location.
[3:17:01 pm] [General] [Info] (PROC 23519)
[3:17:02 pm] [General] [Info] (PROC 23519) [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[3:17:02 pm] [General] [Info] (PROC 23519)     • Xcode at /Applications/Xcode.app/Contents/Developer
[3:17:02 pm] [General] [Info] (PROC 23519)     • CocoaPods version 1.11.3
[3:17:02 pm] [General] [Info] (PROC 23519)
[3:17:02 pm] [General] [Info] (PROC 23519) [✓] Chrome - develop for the web
[3:17:02 pm] [General] [Info] (PROC 23519)     • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[3:17:02 pm] [General] [Info] (PROC 23519)
[3:17:02 pm] [General] [Info] (PROC 23519) [!] Android Studio (not installed)
[3:17:02 pm] [General] [Info] (PROC 23519)     • Android Studio not found; download from https://developer.android.com/studio/index.html
[3:17:02 pm] [General] [Info] (PROC 23519)       (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[3:17:02 pm] [General] [Info] (PROC 23519)
[3:17:02 pm] [General] [Info] (PROC 23519) [✓] IntelliJ IDEA Community Edition (version 2022.1)
[3:17:02 pm] [General] [Info] (PROC 23519)     • IntelliJ at /Users/aat/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5080.210/IntelliJ IDEA CE.app
[3:17:02 pm] [General] [Info] (PROC 23519)     • Flutter plugin can be installed from:
[3:17:02 pm] [General] [Info] (PROC 23519)       🔨 https://plugins.jetbrains.com/plugin/9212-flutter
[3:17:02 pm] [General] [Info] (PROC 23519)     • Dart plugin can be installed from:
[3:17:02 pm] [General] [Info] (PROC 23519)       🔨 https://plugins.jetbrains.com/plugin/6351-dart
[3:17:02 pm] [General] [Info] (PROC 23519)
[3:17:02 pm] [General] [Info] (PROC 23519) [✓] VS Code (version 1.67.1)
[3:17:02 pm] [General] [Info] (PROC 23519)     • VS Code at /Applications/Visual Studio Code.app/Contents
[3:17:02 pm] [General] [Info] (PROC 23519)     • Flutter extension version 3.40.0
[3:17:02 pm] [General] [Info] (PROC 23519)
[3:17:04 pm] [General] [Info] (PROC 23519) [✓] Connected device (2 available)
[3:17:04 pm] [General] [Info] (PROC 23519)     • macOS (desktop) • macos  • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm (Rosetta)
    • Chrome (web)    • chrome • web-javascript • Google Chrome 101.0.4951.64
[3:17:04 pm] [General] [Info] (PROC 23519) [✓] HTTP Host Availability
[3:17:04 pm] [General] [Info] (PROC 23519)     • All required HTTP hosts are available
[3:17:04 pm] [General] [Info] (PROC 23519) ! Doctor found issues in 2 categories.
[3:17:04 pm] [General] [Info] (PROC 23519) exited (0, null)
[3:17:04 pm] [General] [Info] (PROC 23519) closed (0, null)
[3:17:04 pm] [General] [Info] Flutter initialized!
[3:17:04 pm] [General] [Info] Searching for dart
[3:17:04 pm] [General] [Info]     Looking for dart in:
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin/cache/dart-sdk
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin/cache/dart-sdk/bin
[3:17:04 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:17:04 pm] [General] [Info]         /Users/aat/bin
[3:17:04 pm] [General] [Info]         /opt/homebrew/bin
[3:17:04 pm] [General] [Info]         /opt/homebrew/bin
[3:17:04 pm] [General] [Info]         /opt/homebrew/sbin
[3:17:04 pm] [General] [Info]         /usr/local/bin
[3:17:04 pm] [General] [Info]         /usr/bin
[3:17:04 pm] [General] [Info]         /bin
[3:17:04 pm] [General] [Info]         /usr/sbin
[3:17:04 pm] [General] [Info]         /sbin
[3:17:04 pm] [General] [Info]         /opt/local/bin
[3:17:04 pm] [General] [Info]         /usr/local/munki
[3:17:04 pm] [General] [Info]         /usr/local/munki/bin
[3:17:04 pm] [General] [Info]         /Applications/kitty.app/Contents/MacOS
[3:17:04 pm] [General] [Info]         /Applications/kitty.app/Contents/MacOS/bin
[3:17:04 pm] [General] [Info]         /opt/homebrew/opt/fzf/bin
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin/cache/dart-sdk
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin/cache/dart-sdk/bin
[3:17:04 pm] [General] [Info]     Found at:
[3:17:04 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0/bin
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter/bin
[3:17:04 pm] [General] [Info] Following symlink: /Users/aat/Projects/flutter/bin/dart ==> /Users/aat/Projects/flutter/bin/hermit
[3:17:04 pm] [General] [Info]     Candidate paths to be post-filtered:
[3:17:04 pm] [General] [Info]         /Users/aat/Library/Caches/hermit/pkg/flutter-3.0.0
[3:17:04 pm] [General] [Info]         /Users/aat/Projects/flutter
[3:17:04 pm] [General] [Info]     Returning SDK path undefined for dart
[3:17:04 pm] [General] [Info] Done!

Please complete the following information:

  • Operating System and version: 12.3.1 (21E258)
  • VS Code version: 1.67.1 (Universal)
  • Dart extension version: v3.40.0
  • Dart/Flutter SDK version: 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions