Local via WSL2 GUI Is Much Faster Than Windows 10 Native

I was able to get Router mode: Site Domain working.

  1. Install systemd-genie
  2. In /usr/share/dbus-1/session.conf change <listen>...</listen> to tcp:localhost
  3. sudo apt install lxpolkit
  4. add lxpolkit & to .bashrc
  5. Start wsl with wsl genie -s
  6. Start Local with /opt/Local/local and switch to Site Domain
  7. Copy /etc/hosts additions to windows hosts file

This is all really cool feedback, thanks for experimenting and sharing your findings!

In terms of feasibility – anything’s possible – probably! :smiley:

Being a Linux guy for a while now, I’d be especially happy to see something like this be smoothed out and will be advocating for this sort of improvement on our roadmap.

Since it will likely come up – I wonder what the adoption and support of WSL2 is? I took a peek at the various pages on their documentation site and it appears that these features make use of virtualization:

One of the main reasons Local stopped using Docker was the poor experience for many users, especially those that had older versions of Windows, or hardware that didn’t support virtualization.

@robert77 – you seem to have a lot of knowledge about WSL in general – do you have any good links to current information around WSL2 requirements and the numbers around adoption of these features?

Curses… I’ve gone backwards :slight_smile: and I can no longer create a site in Local under WSL

My machine updated to Windows 11 last night (or alteast a dev version of it), I updated WSL today, and installed Local 6. Since it’s an “undefined” error I don’t really know what’s happening.

I was told I could manually edit the windows hosts file to get site domains working (and this would be auto ported into /etc/hosts, but not able to test that give the above fail.

I remember trying to install systemd-genie when i was trying to get a full GUI linux desktop displaying via X410 but ran into trouble there too.

Still it’s pretty interesting to explore.

:skull:

I’m having trouble visualizing how that would work, but maybe it’s possible.

The main hurdle I foresee is that the Local Router (what listens on port 80 and translates the domain to the actual WordPress site listening on a specific port) will be somehow namespaced to the WSL “localhost:80” and not the main machine’s “localhost:80”.

@helgatheviking if you’re not already, run local by cli via /opt/Local/local and check the debugging output. It’s still working for me under the Windows 11 upgrade.

welp… not totally sure what this means.

helga@HELGA:/mnt/c/Users/helga$ /opt/Local/local
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Loading Add-on: %%userDataPath%%/lightning-services/php-8.0.0+2/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%userDataPath%%/lightning-services/php-8.0.0+2/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Loading Add-on: %%resourcesPath%%/lightning-services/mailhog-1.0.0+3/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%resourcesPath%%/lightning-services/mailhog-1.0.0+3/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Loading Add-on: %%resourcesPath%%/lightning-services/mariadb-10.4.10+4/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%resourcesPath%%/lightning-services/mariadb-10.4.10+4/lib/main.js
6/30/2021, 1:01:54 PM [info] [main] AddonLoaderService: Loading Add-on: %%resourcesPath%%/lightning-services/mysql-8.0.16+6/lib/main.js
6/30/2021, 1:01:55 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%resourcesPath%%/lightning-services/mysql-8.0.16+6/lib/main.js
6/30/2021, 1:01:55 PM [info] [main] AddonLoaderService: Loading Add-on: %%resourcesPath%%/lightning-services/nginx-1.16.0+5/lib/main.js
6/30/2021, 1:01:55 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%resourcesPath%%/lightning-services/nginx-1.16.0+5/lib/main.js
6/30/2021, 1:01:55 PM [info] [main] AddonLoaderService: Loading Add-on: %%resourcesPath%%/lightning-services/php-7.3.5+10/lib/main.js
6/30/2021, 1:01:55 PM [info] [main] AddonLoaderService: Successfully Loaded Add-on: %%resourcesPath%%/lightning-services/php-7.3.5+10/lib/main.js
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[GraphQL error]: Message: Unauthenticated., Location: [object Object], Path: logout
6/30/2021, 1:03:19 PM [info] [main] SiteProvisionerService: Creating site folders…
6/30/2021, 1:03:19 PM [info] [main] SiteProvisionerService: Copying service config templates…
6/30/2021, 1:03:19 PM [info] [main] ConfigTemplatesService: Compiling service configs…
6/30/2021, 1:03:19 PM [info] [main] undefined: Initializing MySQL datadir… – {“service”:{},“serviceBinVersion”:{},“dataPath”:“%%site.runData%%/mysql/data”}
6/30/2021, 1:03:31 PM [info] [main] ConfigTemplatesService: Compiling service configs…
6/30/2021, 1:03:31 PM [error] [main] SiteProcessManagerService: Unable to start site. – {“stack”:{}}
6/30/2021, 1:03:36 PM [info] [main] Process: Killing process – {“process”:“mailhog”,“pid”:222}
6/30/2021, 1:03:36 PM [info] [main] Process: Killing process – {“process”:“phpFpm”,“pid”:223}
6/30/2021, 1:03:36 PM [info] [main] Process: Killing process – {“process”:“mysql”,“pid”:228}
6/30/2021, 1:03:36 PM [info] [main] Process: Killing process – {“process”:“nginx”,“pid”:229}
6/30/2021, 1:03:36 PM [error] [main] SiteProvisionerService: Unable to provision site. – {“stack”:{}}
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
undefined
6/30/2021, 1:03:38 PM [warn] [main] undefined: Unhandled Rejection. – {“reason”:{},“p”:{}}
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
{
error: Error: User did not grant permission.
at ChildProcess.exithandler (child_process.js:317:12)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:467:12)
at maybeClose (internal/child_process.js:1048:16)
at Socket. (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:467:12)
at Pipe. (net.js:673:12) {
killed: false,
code: 127,
signal: null,
cmd: ‘cd “/mnt/c/Users/helga”; “/usr/bin/pkexec” --disable-internal-agent /bin/bash -c “echo SUDOPROMPT; setcap cap_net_bind_service=+ep /opt/Local/resources/extraResources/lightning-services/nginx-1.16.0+5/bin/linux/sbin/nginx”’
},
stdout: ‘’,
stderr: ‘Error getting authority: Error initializing authority: Could not connect: No such file or directory\n’,
exitCode: 127
}
6/30/2021, 1:03:38 PM [warn] [main] undefined: Unhandled Rejection. – {“reason”:{“error”:{“killed”:false,“code”:127,“signal”:null,“cmd”:“cd "/mnt/c/Users/helga"; "/usr/bin/pkexec" --disable-internal-agent /bin/bash -c "echo SUDOPROMPT; setcap cap_net_bind_service=+ep %%resourcesPath%%/lightning-services/nginx-1.16.0+5/bin/linux/sbin/nginx"”},“stdout”:“”,“stderr”:“Error getting authority: Error initializing authority: Could not connect: No such file or directory\n”,“exitCode”:127},“p”:{}}

(local:22): libnotify-WARNING **: 13:03:38.285: Failed to connect to proxy

(local:22): libnotify-WARNING **: 13:03:38.286: Failed to connect to proxy

(local:22): libnotify-WARNING **: 13:03:38.286: Failed to connect to proxy
6/30/2021, 1:03:38 PM [info] [main] HostsFileService: Updating hosts with
6/30/2021, 1:03:38 PM [error] [main] HostsFileService: Could not update hosts. – {“error”:{“killed”:false,“code”:127,“signal”:null,“cmd”:“cd "/mnt/c/Users/helga"; export ELECTRON_RUN_AS_NODE="1"; "/usr/bin/pkexec" --disable-internal-agent /bin/bash -c "echo SUDOPROMPT; export ELECTRON_RUN_AS_NODE=\"1\";/opt/Local/local %%appPath%%/main/dns/workers/updateHostsFileWorker.js sandbox.test www.sandbox.test"”},“stdout”:“”,“stderr”:“Error getting authority: Error initializing authority: Could not connect: No such file or directory\n”,“exitCode”:127}
6/30/2021, 1:03:39 PM [info] [main] DeleteSiteService: Deleting %%site.runData%%
(electron) ’ function’ is deprecated and will be removed. Please use ‘shell.trashItem function’ instead.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot read property ‘on’ of undefined
at /opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:1211
at new Promise ()
at Object. (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:1168)
at Generator.next ()
at /opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:330
at new Promise ()
at __awaiter (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:75)
at Object.ipcAsync [as default] (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:1050)
at DeleteSiteService. (/opt/Local/resources/app.asar/main/sites/DeleteSiteService.js:1:2674)
at Generator.next ()
6/30/2021, 1:03:39 PM [warn] [main] undefined: Unhandled Rejection. – {“reason”:{},“p”:{}}
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot read property ‘send’ of undefined
at Object. (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:1305)
at Generator.next ()
at /opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:330
at new Promise ()
at __awaiter (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:75)
at Object.ipcAsync [as default] (/opt/Local/resources/app.asar/renderer/_helpers/ipcAsync.js:1:1050)
at DeleteSiteService. (/opt/Local/resources/app.asar/main/sites/DeleteSiteService.js:1:2674)
at Generator.next ()
at n (/opt/Local/resources/app.asar/main/sites/DeleteSiteService.js:1:132)
6/30/2021, 1:03:39 PM [warn] [main] undefined: Unhandled Rejection. – {“reason”:{},“p”:{}}

(local:22): libnotify-WARNING **: 13:03:40.628: Failed to connect to proxy

(local:22): libnotify-WARNING **: 13:03:40.629: Failed to connect to proxy

(local:22): libnotify-WARNING **: 13:03:40.629: Failed to connect to proxy
6/30/2021, 1:03:40 PM [info] [main] HostsFileService: Updating hosts with
6/30/2021, 1:03:40 PM [error] [main] HostsFileService: Could not update hosts. – {“error”:{“killed”:false,“code”:127,“signal”:null,“cmd”:“cd "/mnt/c/Users/helga"; export ELECTRON_RUN_AS_NODE="1"; "/usr/bin/pkexec" --disable-internal-agent /bin/bash -c "echo SUDOPROMPT; export ELECTRON_RUN_AS_NODE=\"1\";/opt/Local/local %%appPath%%/main/dns/workers/updateHostsFileWorker.js"”},“stdout”:“”,“stderr”:“Error getting authority: Error initializing authority: Could not connect: No such file or directory\n”,“exitCode”:127}

“error: Error: User did not grant permission.”

Do you run Local as an elevated user?

trying to run local results in

-bash: local: can only be used in a function

I’m really moving backwards here. :slight_smile:

sudo local --no-sandbox

gets me the same errors as above. I think this one may be a little too beyond me. It was fun to play around with it though.

FYI, Docker now has explicit support for WSL2:

I think it would be very cool to see that happen for Local.

1 Like

That’s the error that Local gives if it can’t get admin privileges. Local needs this to start the various services like nginx or to change the hosts file.

I don’t think that running Local as an admin would help, since Local is asking for permission to start those services as root.

I think that this is likely the most telling part, but I’m not 100% sure what it means:

6/30/2021, 1:03:38 PM [error] [main] HostsFileService: Could not update hosts. – {“error”:{“killed”:false,“code”:127,“signal”:null,“cmd”:“cd “/mnt/c/Users/helga”; export ELECTRON_RUN_AS_NODE=“1”; “/usr/bin/pkexec” --disable-internal-agent /bin/bash -c “echo SUDOPROMPT; export ELECTRON_RUN_AS_NODE=\“1\”;/opt/Local/local %%appPath%%/main/dns/workers/updateHostsFileWorker.js sandbox.test www.sandbox.test””},“stdout”:"",“stderr”:“Error getting authority: Error initializing authority: Could not connect: No such file or directory\n”,“exitCode”:127}

^^ That’s Local trying to update the Hosts file, and for some reason it’s saying No such file or directory.

That’s the error that Local gives if it can’t get admin privileges.

I thought it read like a permission issue. I did try it with sudo and that didn’t get me much further. any idea why that’s happening?

-bash: local: can only be used in a function

This is on a totally new Ubuntu. My attempt here keeps getting further away…

Should be noted that I am now trying to install Local 6 (looks like above I had Local 5 at least installing)

FYI, local is apparently a reserved keyword

/opt/Local/local %U does launch the GUI of local in WSL2 for me. would be cool to renamed that to localwp instead.

Used this to create a shortcut
sudo ln -s /opt/Local/local /usr/local/bin/localwp

But still running into issues with the site not provisioning or starting

3 Likes

@helgatheviking Make sure you have lxpolkit running in the background with lxpolkit & before you run local. This utility allows an elevated privilege popup window to appear in order to grant access to the /etc/hosts file.

2 Likes

Circled back to this. Updated my Ubuntu container. Purged Local and installed 1.6.2 from the .deb and the app is launching again! and I can create a site!

Router mode is working ok! Still no luck with site domains… I tried installing and running lxpolkit but it shows “No session for pid 23661” and doesn’t load.

Manually editing the /etc/hosts file doesn’t do the trick as Local still thinks the host entry is missing (or I’ve done it wrong)

According to Accessing network applications with WSL | Microsoft Learn

Accessing localhost from a Windows app will show you something running there in WSL. This explains why the router mode works fine.

Per my investigations… the /etc/hosts file is auto-generated from Windows’ hosts file. I thought this would mean I could manually enter the domains in the windows hosts file. and they do get ported into /etc/hosts on reload of WSL. You can also change things so that etc/hosts is not autogenerated, and I tried manually editing the /etc/hosts. Either way I can see that

::1 test.local
127.0.0.1 test.local
::1 www.test.local
127.0.0.1 www.test.local

is definitely ending up in the /etc/hosts

But Local in WSL doesn’t seem to recognize it is there and still thinks it needs to update the hosts file… which is can’t seem to do. So it generates the following error:

2/4/2022, 9:09:54 AM [error] [main] SiteProcessManagerService: Unable to start site. – {“stack”:{}}

(localwp:234): libnotify-WARNING **: 09:09:57.605: Failed to connect to proxy

(localwp:234): libnotify-WARNING **: 09:09:57.607: Failed to connect to proxy

(localwp:234): libnotify-WARNING **: 09:09:57.607: Failed to connect to proxy
2/4/2022, 9:09:57 AM [info] [main] HostsFileService: Updating hosts with
2/4/2022, 9:09:57 AM [warn] [main] Process: 2022-02-04T16:09:54.611879Z 0 [System] [MY-010116] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/linux/bin/mysqld (mysqld 8.0.16) starting as process 349 – {“process”:“mysql”}
2/4/2022, 9:09:57 AM [warn] [main] Process: 2022-02-04T16:09:54.628190Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8MB3 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead. – {“process”:“mysql”}
2/4/2022, 9:09:57 AM [warn] [main] Process: 2022-02-04T16:09:56.933378Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. – {“process”:“mysql”}
2/4/2022, 9:09:57 AM [warn] [main] Process: 2022-02-04T16:09:56.996275Z 0 [System] [MY-010931] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/linux/bin/mysqld: ready for connections. Version: ‘8.0.16’ socket: ‘%%site.runData%%/mysql/mysqld.sock’ port: 10003 MySQL Community Server - GPL. – {“process”:“mysql”}
2/4/2022, 9:09:57 AM [error] [main] HostsFileService: Could not update hosts. – {“error”:{“killed”:false,“code”:127,“signal”:null,“cmd”:“cd "/mnt/c/Users/helga/Sites/woo.dev.cc/wp-content/woocommerce/plugins/woocommerce"; export ELECTRON_RUN_AS_NODE="1"; "/usr/bin/pkexec" --disable-internal-agent /bin/bash -c "echo SUDOPROMPT; export ELECTRON_RUN_AS_NODE=\"1\";/opt/Local/local %%appPath%%/main/dns/workers/updateHostsFileWorker.js testlocal.local www.testlocal.local"”},“stdout”:“”,“stderr”:“Error getting authority: Error initializing authority: Could not connect: No such file or directory\n”,“exitCode”:127}

Is there any workaround to tell Local that the hosts entry is not missing?

I’d love to see proper WSL support from LocalWP themselves, I can’t understate how huge this thread was to helping me get everything setup tonight. I still don’t have Router Mode: Site Domain working @robert77 could you explain setting up lxpolkit anymore?

@ben.turner is this something we can get better support for, with W11 and running GUI apps it seems like the best setup, its so much faster than Windows Local. The local deb didn’t even auto download its dependencies for me.

For anyone who stumbles on this in their WSL setups, if you’re running into a MySQL socket issue this seemed to help me: https://stackoverflow.com/a/66949451/3175165

1 Like

How do you use this lxpolkit properly? When I start it up it shows a pop-up with No session for pix <pid> and nothing else happens.

EDIT:
I would really love to see this working, for both, speed considerations as well as workflow considerations.

I use WSL a lot for GIT, SSH into servers, Kubernetes (gcloud, kubectl), Code edits via VS Code and composer dependencies (I use Bedrock a lot). So I am most of the time running an Ubuntu terminal via WSL anyway. Using the same terminal for Local does make a lot of sense for me.

I just tested this and I got stuck at the permissions part. It doesn’t want to create a site for me. Tested as normal user as well as root user. No luck. No time to investigate this more on my own.

PS: I attempted this not for performance reasons, but for the reason that the WP CLI was showing warning in PHP 7.4 and then on PHP 8.0 it didn’t want to connect to localhost for wp db import to work.

prior to the lxpolkit command in my .bashrc I have the line:

sudo /etc/init.d/dbus start &> /dev/null

not sure if this is related

How do I even run Local after it is installed? I don’t see any Linux shortcut and running the command local doesn’t work either.

I’m kinda new with WSL so bear with me, but I really want to try to utilize this environment.

/opt/Local/local

Ok, so navigated to /opt/Local and ran sudo local which gives me this output:

local: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory

Running local gives me a lot of error messages:

Any ideas on what’s wrong?