Local Community

Local via WSL2 GUI Is Much Faster Than Windows 10 Native

I just wanted to share that with the recent release of WSL2 GUI support, I’ve started running Local on WSL2 and it’s far more performant than the native Windows 10 version. From TTFB of 5s+ to TTFB 600-800ms on the admin page.

Installation required some manual fixes (when does it not with Local) but it’s a huge improvement once it works.

Oh man, super interesting, but I can totally see how this will make things more complicated.

Just so I understand things correctly, are you saying that you installed Local as a Linux application under WSL2?

Which distro are you using and do you have a blog post that outlines the manual fixes you made to get things working?

Yes I installed the linux version of Local directly on WSL. I’m using Debian.

I have not written up instructions, but the basic gist and fixes I can recall are:

  1. Install via dpkg -i local.deb;
  2. sudo apt-get install any missing dependencies;
  3. sudo apt-get install rsync (Local was silently failing to clone my site due to rsync missing)
  4. Set Local -> Preferences -> Advanced -> Router Mode to Localhost (this fixes an issue with Local not being able to modify the hosts file
  5. Clone site

WSL2 GUI support automatically creates a Start Menu shortcut for Local.

If anybody encounters issues trying to reproduce, post specifics and I can help out if it’s something I encountered.

1 Like

@robert77 Do you still use your Windows tools (like a text editor) to edit the code? Can you permanently mount the linux files somewhere? I’m especially kinda reliant on SourceTree for a GUI approach to Git.

I’m still trying to get the WSL gui up and running.

Could be very interesting if Local started using WSL as the “engine” to power it’s sites.

I got local installed! and a site installed!

First steps were:

  1. Joining Windows Insider program, setting insider settting to Dev chanel and then updating to the latest Dev build.
  2. Download the local .deb file and run
    sudo apt install “/mnt/c/users/helga/downloads/local-5.10.5-linux.deb”

@robert77 clicking “open site” currently isn’t doing anything for me. Do I also need to install a linux browser? Change anything in the windows .hosts file?

1 Like

@helgatheviking I use Jetbrains PHPStorm in Windows. The linux mount is available in windows under //Debian/home/user/Local Sites/

Open Site does not work for me either. I manually browse to http://localhost:10004/ in Windows.

Thanks @robert77! It is indeed blazing fast compared to regular local… though I really prefer the URLs over localhost:XX.

I’m toying around with using X410 to load a desktop for the WSL2 ubuntu. no real luck yet, but willing to play around a little more.

Also thinking about switching from sourcetree in Windows (that’s the thing that’s really been holding me back) to something like GitKraken in linux. I think VS Code supports editing files in WSL2, so then I would just move local and gitkraken to Linux apps and that might be enough for me to work with.

@ben.turner no idea how feasible this is, but it could be amazing if Local ran on WSL2 instead of virtualbox.

1 Like

@helgatheviking With the latest version of WSL2 and Local the Open Site button now works for me.

I would also greatly prefer the site domain urls instead of localhost. Unfortunately Local fails with a PolicyKit error when Router Mode is set to Site Domain. I believe this is due to the lack of dbus support in WSL.

If anyone from Local is here, first-class support for WSL would be greatly appreciated. WSL Local is far faster than the Windows-native experience. Changing the hosts file update mechanism would solve the last of my issues.

1 Like

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

2 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