Local on WSL2 on Windows 11 is Far more performant than native

This is splitting out of an earlier thread on the subject that got bogged down in difficulties reporoducing the environment. Below are the verified instructions. This change brought local load time from 5+sec to < 500ms.


In an effort to reproduce my earlier instructions which, obviously, ceased to work on later versions of WSL2, I’ve tracked down the problem to policykit (specifically pkexec) being unable to pop up the GUI sudo box on WSL2, as is required by LocalWP. The earlier instructions used systemd-genie to fix this dbus/policykit/WSL2 issue. That no longer working, I was able to resolve the issue by creating a stub to an alternative GUI sudo utility which Local will use in its place.

Here are the full instructions to get LocalWP running under the latest version of WSL2 Debian on Windows 11 (I haven’t tried Ubuntu):

Install dependencies:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get -y install libaio1 libncurses5 libnss3-tools rsync shared-mime-info desktop-file-utils libxshmfence1 libglu1 libatk1.0-0 libatk-bridge2.0-0 libgtk2.0-0 libgtk-3-0 libgbm-dev libasound2 libnuma-dev libxslt1.1 lxqt-sudo libzip4
sudo apt --fix-broken install
curl -O http://snapshot.debian.org/archive/debian/20190501T215844Z/pool/main/g/glibc/multiarch-support_2.28-10_amd64.deb
sudo dpkg -i multiarch-support_2.28-10_amd64.deb
curl -O http://snapshot.debian.org/archive/debian/20141009T042436Z/pool/main/libj/libjpeg8/libjpeg8_8d1-2_amd64.deb
sudo dpkg -i libjpeg8_8d1-2_amd64.deb
sudo cp /usr/lib/x86_64-linux-gnu/libonig.so.5 /usr/lib/x86_64-linux-gnu/libonig.so.4

Install LocalWP:

sudo dpkg -i local-6.4.3-linux.deb

LocalWP fixes:

sudo setcap 'cap_net_bind_service=+ep' /opt/Local/resources/extraResources/lightning-services/nginx-1.16.0+6/bin/linux/sbin/nginx

sudo nano /usr/bin/kdesudo and set to:

#!/bin/bash
/usr/bin/lxqt-sudo $7
sudo chmod +x /usr/bin/kdesudo

Miscellanous fixes:

If you want the site domain accessible from Windows, sudo nano /mnt/c/Windows/system32/drivers/etc/hosts and add 127.0.0.1 SITENAME.local

If you want the site to open from LocalWP into Windows Chrome:

sudo update-alternatives --install "/bin/host_chrome" "chrome" "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" 1

and add export BROWSER=host_chrome to ~/.bashrc

Now you can pull your site, sit back, and make a cup of coffee.

1 Like

I really appreciated your efforts Robert, they made my life so much easier.
I followed your steps for version 7.1.2 and they worked flawlessly without any change.

Today the 7.2.1 update came and I had to run your steps again, atleast the setcap command and I noticed that it didn’t work this time, but now I know why!

Change this command:

sudo setcap 'cap_net_bind_service=+ep' /opt/Local/resources/extraResources/lightning-services/nginx-1.16.0+6/bin/linux/sbin/nginx

To this:

sudo setcap 'cap_net_bind_service=+ep' /home/USERNAME/.config/Local/lightning-services/nginx-1.16.0+6/bin/linux/sbin/nginx

Be sure to replace USERNAME

2 Likes

Hi there,

You made my day! I was struggling with this issue for hours!

I installed in Ubuntu and for the “browser opening thing” this is what worked for me:

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser “/mnt/c/Program Files/Google/Chrome/Application/chrome.exe” 1

After that, check if is working:

sudo update-alternatives --config x-www-browser

Thank you very much for your contribution!

UPDATE FOR NEW LOCAL 8.0.0

the new path command after updating:

sudo setcap ‘cap_net_bind_service=+ep’ /home/roger/.config/Local/lightning-services/nginx-1.16.0+7/bin/linux/sbin/nginx

1 Like

Thanks for this. On my case, when I try to update to a newer version (I tried various different versions after 7.1.2), I get the following error when I try to start a site or create a new one:

Error: Error: No polkit authentication agent found.
Error executing command as another user: No authentication agent > found.

Did anyone else notice it?

Hi @gsarig!

Could you share a copy of your Local Logs so we can take a further look?

Hi @Nick-B Sorry it took me so long to reply. I’m attaching the logs from a Debian WSL2 setup. My initial report was for Ubuntu, which is my working setup, but since then I reverted back to a functional version of Local. The error is exactly the same on both instances, though.

local-lightning-verbose.log (11.6 KB)

It would be great if you could add official support for WSL. Even with these hacky workarounds, the development experience is so much better and pleasant on WSL compared to native Windows.

Thanks!

It looks like you only shared the Verbose log which isn’t showing us much.

For Ubuntu, have you tried adjusting your Router Mode? Does it work in Localhost but not in Site Domains for example?

Preferences>Advanced>Router Mode>Localhost

Also if it’s only working in 7.1 but not 7.2 or 8.0 then it might be related to what we saw on the thread below which might provide more insight and debugging info:

Thanks @Nick-B the instructions in the link that you’ve shared worked!

I’m attaching the non-verbose logs anyway, but it seems that I had to manually correct the nginx capabilities.
local-lightning.log (2.5 KB)

1 Like

Beautiful @gsarig! Glad to hear that is what you needed. We appreciate the follow-up so we and future users can see what worked here!

1 Like