Skip to content

Flutter SDK installed with Snap is not found when using the Debian package version of VS Code #2791

Closed

Description

@chf2117

When I try to start a new Flutter Project I get this error:

Could not find a Flutter SDK. Please ensure flutter is installed and in your PATH (you may need to restart).

From command line which flutter gives /snap/bin/flutter which points to /usr/bin/snap* (which is not a symlink). I can also run flutter through
/snap/flutter/current/flutter.sh.

Locate SDK does not work for me. I navigate to /snap/bin and press Set Flutter SDK folder and get That folder does not appear to be a Flutter SDK. I get the same error from /snap/flutter/current/flutter.sh

Logs from trying to start a new flutter project:

[2:12:51 PM] [General] [Info] Searching for SDKs...
[2:12:51 PM] [General] [Info] Environment PATH:
[2:12:51 PM] [General] [Info]     /home/cfujimori/.local/bin
[2:12:51 PM] [General] [Info]     /home/cfujimori/lib/bes/gcc-arm-none-eabi-4_9-2014q4/bin/
[2:12:51 PM] [General] [Info]     /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
[2:12:51 PM] [General] [Info]     /usr/local/bin
[2:12:51 PM] [General] [Info]     ...
[2:12:51 PM] [General] [Info]     /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]     /home/cfujimori/.local/bin/
[2:12:51 PM] [General] [Info]     /snap/bin
[2:12:51 PM] [General] [Info]     /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]     /home/cfujimori/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/
[2:12:51 PM] [General] [Info] Searching for flutter
[2:12:51 PM] [General] [Info]     Looking for flutter in:
[2:12:51 PM] [General] [Info]         /home/cfujimori/.local/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/lib/bes/gcc-arm-none-eabi-4_9-2014q4/bin/
[2:12:51 PM] [General] [Info]         /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
[2:12:51 PM] [General] [Info]         /usr/local/bin
[2:12:51 PM] [General] [Info]         ...
[2:12:51 PM] [General] [Info]         .../bin
[2:12:51 PM] [General] [Info]         /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/.local/bin/
[2:12:51 PM] [General] [Info]         /snap/bin
[2:12:51 PM] [General] [Info]         /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/
[2:12:51 PM] [General] [Info]     Found at:
[2:12:51 PM] [General] [Info]         /snap/bin
[2:12:51 PM] [General] [Info] Following symlink: /snap/bin/flutter ==> /usr/bin/snap
[2:12:51 PM] [General] [Info]     Candidate paths to be post-filtered:
[2:12:51 PM] [General] [Info]         /usr
[2:12:51 PM] [General] [Info]     Returning SDK path undefined for flutter
[2:12:51 PM] [General] [Info] Searching for dart
[2:12:51 PM] [General] [Info]     Looking for dart in:
[2:12:51 PM] [General] [Info]         /home/cfujimori/.local/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/lib/bes/gcc-arm-none-eabi-4_9-2014q4/bin/
[2:12:51 PM] [General] [Info]         /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
[2:12:51 PM] [General] [Info]         /usr/local/bin
[2:12:51 PM] [General] [Info]         ...
[2:12:51 PM] [General] [Info]         .../bin
[2:12:51 PM] [General] [Info]         /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/.local/bin/
[2:12:51 PM] [General] [Info]         /snap/bin
[2:12:51 PM] [General] [Info]         /snap/flutter/current/bin
[2:12:51 PM] [General] [Info]         /home/cfujimori/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/
[2:12:51 PM] [General] [Info]     Found at:
[2:12:51 PM] [General] [Info]     Candidate paths to be post-filtered:
[2:12:51 PM] [General] [Info]     Returning SDK path undefined for dart
[2:12:51 PM] [General] [Info] !! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.14.1
Flutter extension: 3.14.1 (not activated)

App: Visual Studio Code
Version: 1.47.3
Platform: linux

Workspace type: Unknown (No SDK)
Analyzer type: DAS
Multi-root?: undefined

Dart SDK:
    Loc: undefined
    Ver: undefined
Flutter SDK:
    Loc: undefined
    Ver: undefined

HTTP_PROXY: undefined
NO_PROXY: undefined

Activity

  1. DanTup commented on Sep 15, 2020

    @DanTup
    Member

    @MarcusTomlinson there's nothing in the log above about Snap, but I would expect to see this log (there's no path that bypasses the call to findFlutterSnapSdkRoot):

    async function findFlutterSnapSdkRoot(logger: Logger, folder: string): Promise<string | undefined> {
    	if (isLinux && fs.existsSync(flutterSnapScript)) {
    		logger.info(`Found Flutter snap script`);
    

    Based on the log saying Platform: Linux I think the isLinux check is probably working, so I wonder if the exist check for /snap/flutter/current/flutter.sh might be failing? @chf2117 specifically mentioned it can be run from there, so presumably it's not. I'm not familiar with how Snap sandboxes things though - can you think of any reason why this might not work?

  2. added
    awaiting infoRequires more information from the customer to progress
    on Sep 15, 2020
  3. DanTup commented on Sep 15, 2020

    @DanTup
    Member

    I'm also not entirely sure what this means:

    From command line which flutter gives /snap/bin/flutter which points to /usr/bin/snap*

    If /snap/bin/flutter is a link - shouldn't it point to an executable script that runs Flutter? /usr/bin/snap* does not seem Flutter-specific?

  4. MarcusTomlinson commented on Sep 15, 2020

    @MarcusTomlinson
    Contributor

    @chf2117, it may be that your copy of the Flutter SDK has corrupted somehow.

    Please try re-initialising the SDK like so:

    rm -rf ~/snap/flutter
    flutter channel dev
    flutter upgrade
    flutter config --enable-linux-desktop
    

    Then relaunch VS Code.

  5. chf2117 commented on Sep 15, 2020

    @chf2117
    Author

    @MarcusTomlinson I ran those commands and hit the same problem when trying to start a new flutter project. The logs are the same.

  6. DanTup commented on Sep 16, 2020

    @DanTup
    Member

    @chf2117 can you confirm what the file/link at /snap/bin/flutter is? Above you said it "points to /usr/bin/snap*" but I'm not exactly sure what that means (though my Linux experience is somewhat limited). Thanks!

  7. chf2117 commented on Sep 16, 2020

    @chf2117
    Author

    /snap/bin/flutter is a symlink to/usr/bin/snap

    /usr/bin/snap is an executable. I don't know much(anything) about snap, but it was the recommended way to install flutter on the dev site. Surprisingly /snap/bin/android-studio is also a symlink to /usr/bin/snap. I guess snap must be looking at how it is called from the command line and changing it's behavior accordingly.

    Worked around this issue by changing in constants.ts

    -export const flutterExecutableName = isWin ? "flutter.bat" : "flutter";
    +export const flutterExecutableName = isWin ? "flutter.bat" : "flutter.sh";
    
  8. MarcusTomlinson commented on Sep 16, 2020

    @MarcusTomlinson
    Contributor

    @chf2117 first question: are you using the VS Code snap or deb package?

    If you navigate to your project folder in the terminal and run flutter run -d linux does it work? what about if you run /snap/flutter/current/flutter.sh run -d linux?

    @DanTup I don't know what's happening here, the log looks odd. The extension should be finding and running /snap/flutter/current/flutter.sh, it shouldn't be preferring the flutter found in /snap/bin. There's no sandboxing involved whatsoever when calling /snap/flutter/current/flutter.sh directly (as we should be doing). Calling flutter from /snap/bin on the other hand indeed triggers snapd sandboxing etc, this is why we have the directly-executable script.

  9. chf2117 commented on Sep 16, 2020

    @chf2117
    Author

    @MarcusTomlinson I am using the deb package

    flutter run -d chrome does work, but flutter run -d linux does not work.

    cfujimori@cfujimori:~/flutter/boxgame$ flutter run -d linux
    Launching lib/main.dart on Linux in debug mode...
    Exception: No Linux desktop project configured. See
    https://github.com/flutter/flutter/wiki/Desktop-shells#create to learn about
    adding Linux support to a project.
    

    After running flutter create --platforms=linux . then flutter run -d linux worked

    snap/flutter/current/flutter.sh run -d linux works.

  10. MarcusTomlinson commented on Sep 17, 2020

    @MarcusTomlinson
    Contributor

    @chf2117 ah, I suspect this is an issue in using the flutter snap with the code deb package. Would you mind giving the vs code snap package a try?

    snap install code --classic
    snap run code
    
  11. DanTup commented on Sep 17, 2020

    @DanTup
    Member

    @MarcusTomlinson

    @DanTup I don't know what's happening here, the log looks odd. The extension should be finding and running /snap/flutter/current/flutter.sh, it shouldn't be preferring the flutter found in /snap/bin. There's no sandboxing involved whatsoever when calling /snap/flutter/current/flutter.sh directly (as we should be doing).

    Yeah, I don't understand why we're not. It seems like this condition is failing:

    if (isLinux && fs.existsSync(flutterSnapScript)) {
    logger.info(`Found Flutter snap script`);

    Since "Found Flutter snap script" is not appearing in the log. That means we're not running any Snap code, and just doing the normal searching of PATH. Even if running the Debian package, that shouldn't prevent an exists check on /snap/flutter/current/flutter.sh failing, right?

  12. MarcusTomlinson commented on Sep 17, 2020

    @MarcusTomlinson
    Contributor

    Even if running the Debian package, that shouldn't prevent an exists check on /snap/flutter/current/flutter.sh failing, right?

    It shouldn’t no. I wonder if it’s the sandboxing of vs code in a snap that’s leading to the snap script taking some sort of preference over the flutter in PATH. I’ll have a debug of this later today.

  13. MarcusTomlinson commented on Sep 17, 2020

    @MarcusTomlinson
    Contributor

    @DanTup, I just gave this a try on the latest vs code deb from https://code.visualstudio.com/docs/setup/linux#_debian-and-ubuntu-based-distributions and it still works fine for me. Could an older version of vs code cause issues perhaps?

    @chf2117, I see from the log you're running v1.47.3 of vs code, could you try installing the latest (1.49.0) either via snap or from the link above.

  14. DanTup commented on Sep 17, 2020

    @DanTup
    Member

    Could an older version of vs code cause issues perhaps?

    I wouldn't expect so. I did wonder if it was a version of the extension without the Snap work (that would cause this behaviour and no Snap-specific code in the log), however the log above says 3.14.1 which is the most recent.

    If installing the latest VS Code doesn't help, I can make a dev build that has additional logging so we can figure out exactly why it's not getting to that code and go from there.

  15. chf2117 commented on Sep 17, 2020

    @chf2117
    Author

    The latest version of VS Code installed through snap works.

  16. 1 remaining item

  17. MarcusTomlinson commented on Sep 21, 2020

    @MarcusTomlinson
    Contributor

    If installing the latest VS Code doesn't help...

    Yeah, following from this, I'd say we can close this issue now. If this becomes a more wide-spread issue, I'm sure we'll hear about it :)

  18. changed the title [-]Could not find Flutter SDK (Linux/Snap)[/-] [+]Flutter SDK installed with Snap is not found when using the Debian package version of VS Code[/+] on Sep 21, 2020
  19. removed
    awaiting infoRequires more information from the customer to progress
    on Sep 21, 2020
  20. DanTup commented on Sep 21, 2020

    @DanTup
    Member

    sgtm, thanks both!

  21. teohhanhui commented on Oct 16, 2020

    @teohhanhui

    I'm facing a similar issue. Flutter is installed through Snap, and Visual Studio Code is installed through AUR: https://aur.archlinux.org/packages/visual-studio-code-bin

    Following symlink: /var/lib/snapd/snap/bin/flutter ==> /usr/bin/snap

    It seems like the extension is just following the symlink blindly without taking into consideration how Snap works.

    Considering that Snap is the recommended install method, this needs to be fixed.

    [3:39:46 PM] [General] [Info] Searching for SDKs...
    [3:39:46 PM] [General] [Info] Environment PATH:
    [3:39:46 PM] [General] [Info]     /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]     /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]     /usr/local/bin
    [3:39:46 PM] [General] [Info]     /usr/local/sbin
    [3:39:46 PM] [General] [Info]     /usr/bin
    [3:39:46 PM] [General] [Info]     /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]     /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info]     /usr/bin/site_perl
    [3:39:46 PM] [General] [Info]     /usr/bin/vendor_perl
    [3:39:46 PM] [General] [Info]     /usr/bin/core_perl
    [3:39:46 PM] [General] [Info]     /var/lib/snapd/snap/bin
    [3:39:46 PM] [General] [Info]     /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]     /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info] Searching for flutter
    [3:39:46 PM] [General] [Info]     Looking for flutter in:
    [3:39:46 PM] [General] [Info]         /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]         /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]         /usr/local/bin
    [3:39:46 PM] [General] [Info]         /usr/local/sbin
    [3:39:46 PM] [General] [Info]         /usr/bin
    [3:39:46 PM] [General] [Info]         /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]         /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/site_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/site_perl/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/vendor_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/vendor_perl/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/core_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/core_perl/bin
    [3:39:46 PM] [General] [Info]         /var/lib/snapd/snap/bin
    [3:39:46 PM] [General] [Info]         /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]         /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info]     Found at:
    [3:39:46 PM] [General] [Info]         /var/lib/snapd/snap/bin
    [3:39:46 PM] [General] [Info] Following symlink: /var/lib/snapd/snap/bin/flutter ==> /usr/bin/snap
    [3:39:46 PM] [General] [Info]     Candidate paths to be post-filtered:
    [3:39:46 PM] [General] [Info]         /usr
    [3:39:46 PM] [General] [Info]     Returning SDK path undefined for flutter
    [3:39:46 PM] [General] [Info] Searching for dart
    [3:39:46 PM] [General] [Info]     Looking for dart in:
    [3:39:46 PM] [General] [Info]         /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]         /home/teohhanhui/.local/bin
    [3:39:46 PM] [General] [Info]         /usr/local/bin
    [3:39:46 PM] [General] [Info]         /usr/local/sbin
    [3:39:46 PM] [General] [Info]         /usr/bin
    [3:39:46 PM] [General] [Info]         /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]         /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/site_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/site_perl/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/vendor_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/vendor_perl/bin
    [3:39:46 PM] [General] [Info]         /usr/bin/core_perl
    [3:39:46 PM] [General] [Info]         /usr/bin/core_perl/bin
    [3:39:46 PM] [General] [Info]         /var/lib/snapd/snap/bin
    [3:39:46 PM] [General] [Info]         /var/lib/flatpak/exports/bin
    [3:39:46 PM] [General] [Info]         /usr/lib/jvm/default/bin
    [3:39:46 PM] [General] [Info]     Found at:
    [3:39:46 PM] [General] [Info]     Candidate paths to be post-filtered:
    [3:39:46 PM] [General] [Info]     Returning SDK path undefined for dart
    [3:39:46 PM] [General] [Info] !! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!
    
    Dart Code extension: 3.15.1
    Flutter extension: 3.15.1 (not activated)
    
    App: Visual Studio Code
    Version: 1.50.0
    Platform: linux
    
    Workspace type: Unknown (No SDK)
    Analyzer type: DAS
    Multi-root?: undefined
    
    Dart SDK:
        Loc: undefined
        Ver: undefined
    Flutter SDK:
        Loc: undefined
        Ver: undefined
    
    HTTP_PROXY: undefined
    NO_PROXY: undefined
    [3:39:47 PM] [General] [Error] No Dart or Flutter SDK was found. Suppressing prompt because it doesn't appear that a Dart/Flutter project is open.
    
    $ flutter doctor -v
    [✓] Flutter (Channel stable, 1.22.1, on Linux, locale en_US.UTF-8)
        • Flutter version 1.22.1 at /home/teohhanhui/snap/flutter/common/flutter
        • Framework revision f30b7f4db9 (8 days ago), 2020-10-08 10:06:30 -0700
        • Engine revision 75bef9f6c8
        • Dart version 2.10.1
    
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /home/teohhanhui/Android/Sdk
        • Platform android-30, build-tools 30.0.2
        • Java binary at: /opt/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [!] Android Studio
        • Android Studio at /opt/android-studio
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [!] Connected device
        ! No devices available
    
    ! Doctor found issues in 2 categories.
    
  22. DanTup commented on Oct 16, 2020

    @DanTup
    Member

    This does look similar to the description above:

    Following symlink: /var/lib/snapd/snap/bin/flutter ==> /usr/bin/snap
    

    I'm not very familiar with Snap (or much Linux 😄) but it seems strange that a flutter command is symlinked to a generic snap executable. This is preventing us from locating the SDK correctly and I don't think it can be fixed here without an understanding of what's happening there. We resolve symlinks because it's very common for Flutter to be installed in one location and symlinked from a folder on PATH, so in this case we end up with /usr/bin/snap which is not a Flutter SDK.

    @MarcusTomlinson any ideas what's happening here (what's creating the symlink or why)?

  23. MarcusTomlinson commented on Oct 16, 2020

    @MarcusTomlinson
    Contributor

    Yeah all links in /snap/bin/* point to /usr/bin/snap, nothing wrong there.

    Looks like the issue here is that the extension expects to find the snap in /snap/ but Arch Linux stores it in /var/lib/snapd/snap/. @teohhanhui, to work around this, click the "Locate SDK" button in the popup and browse to /home/teohhanhui/snap/flutter/common/flutter (as shown in your flutter doctor output). Alternatively (as suggested above) you could try the VS Code snap (snap install code --classic).

    @DanTup, it may not be a bad idea for the extension to actually scrape the output of flutter doctor -v to locate the SDK path rather than following the link. wdyt?

  24. DanTup commented on Oct 19, 2020

    @DanTup
    Member

    @DanTup, it may not be a bad idea for the extension to actually scrape the output of flutter doctor -v to locate the SDK path rather than following the link. wdyt?

    In the past we've had issues where people have had flutter or dart binaries in PATH that weren't these SDKs (for example this npm package) which is why we do some basic checking to see if it looks like an SDK before running it.

    Would another option by changing our check from just "/snap/flutter/common/flutter" to also "~/snap/flutter/common/flutter"?

  25. MarcusTomlinson commented on Oct 19, 2020

    @MarcusTomlinson
    Contributor

    Would another option by changing our check from just "/snap/flutter/common/flutter" to also "~/snap/flutter/common/flutter"?

    Yeah, essentially we need the IDE to find the SDK in ~/snap/flutter/common/flutter and go from there. It's a tricky situation with PATH pointing to /snap/bin/flutter... I wonder how the Android studio extension finds/prioritises SDK path. As you can see here, the IDE had found the SDK fine, it just wouldn't work before my bootstrapping stuff landed.

  26. DanTup commented on Oct 19, 2020

    @DanTup
    Member

    I've opened #2886 to track the Arch issue specifically, and added some further comments there.

  27. burtsevyg commented on Nov 7, 2020

    @burtsevyg
  28. DanTup commented on Nov 9, 2020

    @DanTup
    Member

    @burtsevyg I'm not sure I understand the question. The same Flutter SDK should work for both, though I'm not sure how Android Studio locates the SDK (whether you'd need to explicitly tell it where it is, or it will be found on PATH).

  29. burtsevyg commented on Nov 9, 2020

    @burtsevyg

    As I understand flutter snap package equal flutter sdk which is needed for run Android Studio but Android Studio does not recognise in /snap/flutter/current flutter sdk directory. And I downloaded flutter sdk manually.

  30. DanTup commented on Nov 9, 2020

    @DanTup
    Member

    If you have installed Flutter manually and added it to PATH (see step 3 of https://flutter.dev/docs/get-started/install/linux#install-flutter-manually) and Android Studio does not recognise it, I would file an issue at https://github.com/flutter/flutter-intellij/. Unfortunately I don't work with Android Studio so I'm not very familiar with how it locates the SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions