Repository navigation
Flutter SDK installed with Snap is not found when using the Debian package version of VS Code #2791
Copy link
Copy link
Closed
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
DanTup commentedon Sep 15, 2020
@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):Based on the log saying
Platform: LinuxI think theisLinuxcheck is probably working, so I wonder if the exist check for/snap/flutter/current/flutter.shmight 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?DanTup commentedon Sep 15, 2020
I'm also not entirely sure what this means:
If
/snap/bin/flutteris a link - shouldn't it point to an executable script that runs Flutter?/usr/bin/snap*does not seem Flutter-specific?MarcusTomlinson commentedon Sep 15, 2020
@chf2117, it may be that your copy of the Flutter SDK has corrupted somehow.
Please try re-initialising the SDK like so:
Then relaunch VS Code.
chf2117 commentedon Sep 15, 2020
@MarcusTomlinson I ran those commands and hit the same problem when trying to start a new flutter project. The logs are the same.
DanTup commentedon Sep 16, 2020
@chf2117 can you confirm what the file/link at
/snap/bin/flutteris? 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!chf2117 commentedon Sep 16, 2020
/snap/bin/flutteris a symlink to/usr/bin/snap/usr/bin/snapis 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-studiois 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
MarcusTomlinson commentedon Sep 16, 2020
@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 linuxdoes 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 theflutterfound in/snap/bin. There's no sandboxing involved whatsoever when calling/snap/flutter/current/flutter.shdirectly (as we should be doing). Callingflutterfrom/snap/binon the other hand indeed triggers snapd sandboxing etc, this is why we have the directly-executable script.chf2117 commentedon Sep 16, 2020
@MarcusTomlinson I am using the deb package
flutter run -d chromedoes work, butflutter run -d linuxdoes not work.After running
flutter create --platforms=linux .thenflutter run -d linuxworkedsnap/flutter/current/flutter.sh run -d linuxworks.MarcusTomlinson commentedon Sep 17, 2020
@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?
DanTup commentedon Sep 17, 2020
@MarcusTomlinson
Yeah, I don't understand why we're not. It seems like this condition is failing:
Dart-Code/src/extension/sdk/utils.ts
Lines 455 to 456 in 3747184
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.shfailing, right?MarcusTomlinson commentedon Sep 17, 2020
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.
MarcusTomlinson commentedon Sep 17, 2020
@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.
DanTup commentedon Sep 17, 2020
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.
chf2117 commentedon Sep 17, 2020
The latest version of VS Code installed through snap works.
1 remaining item
MarcusTomlinson commentedon Sep 21, 2020
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 :)
[-]Could not find Flutter SDK (Linux/Snap)[/-][+]Flutter SDK installed with Snap is not found when using the Debian package version of VS Code[/+]DanTup commentedon Sep 21, 2020
sgtm, thanks both!
teohhanhui commentedon Oct 16, 2020
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
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.
DanTup commentedon Oct 16, 2020
This does look similar to the description above:
I'm not very familiar with Snap (or much Linux 😄) but it seems strange that a
fluttercommand is symlinked to a genericsnapexecutable. 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 onPATH, so in this case we end up with/usr/bin/snapwhich is not a Flutter SDK.@MarcusTomlinson any ideas what's happening here (what's creating the symlink or why)?
MarcusTomlinson commentedon Oct 16, 2020
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 yourflutter doctoroutput). 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 -vto locate the SDK path rather than following the link. wdyt?DanTup commentedon Oct 19, 2020
In the past we've had issues where people have had
flutterordartbinaries inPATHthat 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"?MarcusTomlinson commentedon Oct 19, 2020
Yeah, essentially we need the IDE to find the SDK in
~/snap/flutter/common/flutterand 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.DanTup commentedon Oct 19, 2020
I've opened #2886 to track the Arch issue specifically, and added some further comments there.
burtsevyg commentedon Nov 7, 2020
@DanTup Is Flutter the same as Flutter SDK from https://flutter.dev/docs/get-started/test-drive?tab=androidstudio ?
DanTup commentedon Nov 9, 2020
@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).
burtsevyg commentedon Nov 9, 2020
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.
DanTup commentedon Nov 9, 2020
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.