flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Incompatibility with WSL2

Open alihoseiny opened this issue 1 year ago • 1 comments

The plugin is unable to find and work with flutter sdk on the WSL2.

Steps to Reproduce

After installing flutter SDK on the WSL2 and making sure that it is working using flutter doctor command and build commands, After adding the bin path to the "Flutter SDK path", it shows following error: "Cannot Save Settings: Flutter SDK is not found in the specified location".

Version info

[✓] Flutter (Channel stable, 3.22.1, on Ubuntu 22.04.4 LTS 5.15.146.1-microsoft-standard-WSL2, locale C.UTF-8)
    • Flutter version 3.22.1 on channel stable at /usr/bin/flutter-sdk
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (6 days ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
    • pkg-config version 0.29.2
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install libgtk-3-dev)

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.4 LTS 5.15.146.1-microsoft-standard-WSL2
    • Chrome (web)    • chrome • web-javascript • Google Chrome 125.0.6422.60

[✓] Network resources
    • All expected network resources are available.

alihoseiny avatar May 28 '24 08:05 alihoseiny

Based on https://github.com/flutter/flutter/issues/142619 my guess is WSL2 is not supported and it is not planned to add the support.

rekire avatar May 30 '24 05:05 rekire

I don't know enough about WSL to guess whether this should work or not. When you are using WSL, is it as though both your IDE and the Flutter SDK are on a linux machine? Is file finding very different from normal linux in this system?

helin24 avatar Sep 04 '25 19:09 helin24

Maybe I can clarify some details. WSL is the Linux subsystem on Windows where you can run elf files and such things. So when we talk about WSL it's always Windows under the hood.

I tried a long time ago to build my App from WSL to use the same scripts on each platform. The main issue when you use in Windows and WSL is that the build tools like the dart command are the Windows binaries which can be executed for the WSL but behave like they were run on Windows which breaks the build.

The easiest workaround is to start from the flutter command in the WSL context the flutter.bat which moves the build back to the window side with on a Windows shell. However when you install everything in WSL it might work, but who wants to install everything twice including Java etc.

I made in the past a PR for starting a Windows shell from WSL, but it was rejected for the reason that cross compilation is not supported.

rekire avatar Sep 04 '25 20:09 rekire

Thank you very much for the clarification!

However when you install everything in WSL it might work, but who wants to install everything twice including Java etc.

Okay, this is the setup I was initially imagining, but I understand now that this would largely defeat the purpose of WSL.

If instead we are trying to call something like flutter run (linux-like command) and call the windows flutter.bat file, then that seems like a flutter tooling issue that's pretty specialized and we won't be able to support.

helin24 avatar Sep 04 '25 21:09 helin24