go-flutter-desktop / go-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
https://hover.build/
BSD 3-Clause "New" or "Revised" License
5.86k stars 282 forks source link

Please add a wiki page for WSL setup #610

Open cosban opened 3 years ago

cosban commented 3 years ago

Describe the feature you'd like

Windows users may want to run hover/flutter using wsl for development. The following would probably be good to add to a wiki, or to the hover readme.

Installing on Linux in WSL

For developers on windows, it may be desired to run and build within a WSL linux environment.

  1. Perform all prerequisite setup within the WSL linux image
    1. Set up golang 1.13 or higher
    2. Install flutter within the image
    3. Install all required dependencies for the chosen WSL linux distro
  2. Windows insiders with OS builds >=21362 should follow Microsoft's official documentation
    1. Everyone else should continue along
  3. Set the DISPLAY variable within the the WSL linux image depending on your WSL version
    1. Check WSL version using wsl.exe -l --verbose in the windows host
    2. If using WSL1 run export DISPLAY=localhost:0.0
    3. If using WSL2 run export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
    4. Feel free to add these to /etc/profile, ~/.bashrc, ~/.zshrc, etc. if it is desired to have them be run automatically
  4. Set up the windows host to display WSL gui programs.
    1. Install an x-server for windows (VcXsrv is a good one)
    2. You will likely need to modify your firewall in order to display the applications since the host connects to WSL as a public network
      1. Verify that a public Inbound Rule for your x-server has been created and can be used by the 127.16.0.0/12 range
      2. wsl-windows-toolbar-launcher does a good job showing you how to do this
  5. Launch your windows x-server and run your app
    1. If using VcXsrv, the best thing to do is to run xlaunch in order to configure the x-server behavior