Local via WSL2 GUI Is Much Faster Than Windows 10 Native

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?

You’re missing some dependencies.

sudo apt install libncurses5 libnss3-tools libtinfo5 libxshmfence1 libatk-bridge2.0-0 libgtk-3.0 libgbm-dev libasound2 rsync

FYI I’ve been successful getting this running on a WSL2 Debian instance. I’ve had no luck on Ubuntu (I can’t get systemd dbus working).

Robert

Unfortunately I’m still getting roughly the same error running local

sudo local gives me this:

There’s a system command ‘local’ which may have run instead of LocalWP. That output looks related.

Try it with the full path /opt/Local/local or ./local if you’re in the directory.

Ok, I’m getting closer, but still errors. Tried to do some google searches, but no luck.

Running ./local gives me this:

Running sudo ./local gives me this:

Any ideas? I really appreciate the help.

I got the same error using the Ubuntu distribution. It works for me on Debian.

I do have a working version of LocalWP on WSL/Ubuntu. Although I still lack site domain functionality which is the domains like site-name.local, so I am forced to run on the localhost and port number provided for each site.

@robert77 can you explain the lxpolkit setup process for overcoming the Uh-oh could not update host files error, and them not resolving?

@oeknudsen what do you get when you simply run the follow in the terminal /opt/Local/local what I learned was their is a difference here, at least in WSL/Ubuntu (or for me at the very least), sudo local vs /opt/Local/local are two different “instances” of the Local package, it appears one installs its Local Sites folder to the root directory of your WSL/Ubuntu folder and one installs to another directory, possibly the home directory but do not quote me on that last part I would need to double check. Only /opt/Local/local works for me in WSL/Ubuntu hover after I get it installed I can launch it directly from the Windows Start menu on Windows 11 by just searching Local but as I mention above this is only working with localhost domains, meaning something like localhost:1004/wp-admin with the port number assigned for each site, this is controlled under Local > Preferences > Avanced > Router Mode. Let me know you’re results maybe I can help you move forward.

I have my installation steps for WSL/Ubuntu I’ll track down and revise and get them posted for anyone else, I made them quite early in my process of getting it working but I know they’re good.

@ben.turner Think anyone on your side can lend a solution to the cannot update host files aspect? It really seems like a bug not just an environment issue or is this an issue with the fact that sudo local and /opt/Local/local are different “instances” of Local. Would this work if we could get the sudo local version working in WSL?

The limitation I run into with sudo local is when I create a site I get the error in the image attached. This is a mysqld.socket issue and has to do with the sockets that get “created” for each site.

Great, so there’s hope!
When running /opt/Local/local I get this error:

So that’s not a very clear error, at least to me.

Something to try is to get the 6.4.1 release from Releases - Local and upgrade LocalWP, wget https://cdn.localwp.com/releases-stable/6.4.1+5978/local-6.4.1-linux.deb then sudo dpkg -i local6.4.1-linux.deb followed up by running something like sudo apt update --fix-missing and/or sudo apt install -f

Let me know how this works out for you.

@ben.turner This is possibly the same reason I need to change my DB_HOST to the pdo_mysql.default_socket file address in my WP Config file to get wp cli working.

define( ‘DB_HOST’, ‘localhost:/home/USERNAME/.config/Local/run/igdkB_d0B/mysql/mysqld.sock’ );

Just a thought.

Unfortunately, I still get the same error.

Check the logs in /mnt/wslg. I saw this error as well on Ubuntu, it’s related to wslg and systemd, not the database connection. In order to get this working I had to get lxpolkit working to enable the sudo password prompt pop-up. In order to get lxpolkit working I had to get systemd/dbus working.

systemd-genie and some googling did it for me on a Debian WSL instance. I was not able to get this working on the Ubuntu version.

Try googling for wsl dbus systemd.