The local-cli is dead. Long live local-cli [A LocalWP Addon to resurrect local-cli].


Deprecated: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /data/sites/web/remonpelnl/www/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 84

Deprecated: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /data/sites/web/remonpelnl/www/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 84

Some of you might remember lbl, my handy little “missing CLI for Local” script from a few years back. Starting, stopping and restarting sites in that script leaned on @getflywheel/local-cli, the official command line tool from the Local folks.

Leaned. Past tense.

Because that tool is deprecated. It talks to Local’s GraphQL server, and that conversation has become… let’s call it “unreliable”. And on the days it did work, it only worked if your shell happened to be on the right Node version. cd into a project with an .nvmrc, and poof; a stack trace, or a Node that runs in an x86 container and can’t even reach Local anymore.

I have a zsh function that starts the site of the folder I cd into. It has been throwing errors lately. I needed a fix … get it? … a f…. never mind, I’ll see myself out.

This is Addon number 8 of 7 ;)

The Problem

Local has no supported way to control sites from the command line. There is the deprecated local-cli, which is GraphQL and Node-based. Since Local-CLI is deprecated, there is nothing stopping the LocalWP team from silently discontinuing the GraphQL API. So I created my own.

And I am, as stated before, a terminal type of person. I want local-cli start-site mysite to just… start the site. From a shell script, from a cron job, from a CI runner, from that zsh function. Without caring which Node is active, or whether Node is active at all.

So what do we do about it?

Once again, everything needed is already in the pantry;

  • An addon runs inside Local’s own main process, and gets handed the same siteProcessManager the Start and Stop buttons in the UI use. No GraphQL required.
  • Node (the one inside Local, the only one that matters here) can open an HTTP server on a Unix domain socket. No TCP port, no token; the file permissions on the socket are the authentication. Only the user running Local can talk to it.
  • curl speaks Unix sockets. curl is everywhere. And curl has never once been broken by nvm.

So the client side doesn’t need Node at all. A plain POSIX shell script, a curl call, done. Glue was applied. ;)

The Solution

CLI Bridge: a Local addon that runs a tiny HTTP server on a Unix socket inside Local, plus a local-cli shell script that talks to it. It is a drop-in replacement for the deprecated tool; same command names, same ID | Name | Status table, so scripts written against the old local-cli keep working. Mine did, without changing a single line.

A site can be referenced by its ID, its domain or its name, case-insensitive. A unique prefix works too; an ambiguous prefix lists the candidates and refuses to guess.

The details that make it actually usable;

  • Add --json for the raw response (ideal for jq) or --plain for tab-separated ID Name Domain Status (ideal for cut/awk).
  • Starting a site that is already running, or stopping one that is already halted, is a successful no-op. Start/stop/restart return once Local reports the transition finished, typically within a few seconds.
  • Proper exit codes: 0 ok, 1 the command failed (unknown site, Local refused), 2 Local or the addon is not reachable, 64 you typed it wrong.
  • Start/stop go through Local’s own machinery, exactly the code path the buttons use. Local’s UI updates as if you clicked. Because, in a way, you did.
  • Don’t like the script? Talk to the bridge directly: curl --unix-socket ~/.local-cli-bridge/bridge.sock -X POST http://local/sites/wp/start
  • Socket and bookkeeping live in ~/.local-cli-bridge/ (mode 0700/0600) and are cleaned up when Local quits. On Windows it’s a named pipe; untested by me, so please, tell me what happens.

Adding a command later is one route in the addon and one line in the shell script’s case. PRs welcome, as always.

Full transparency on quality assurance; tested by 1 person on Local 10.1.2. The addon only touches siteData, siteProcessManager and localLogger, which are identical in Local 9, so it should work there too. Feel free to confirm or deny.

Get it

Source on GitHub: rmpel/Local-CLI-Bridge. Be sure to read the notes.

Install from source (MacOS and Linux);

Restart Local to make it visible in the Installed addons list, toggle on as usual, restart Local once more when it asks you to, and run local-cli ping.

Install from a dist file (All OS); grab the latest .tgz from the dist folder, or build it with ./scripts/build.sh, and use the “Install from disk” feature in LocalWP. You’ll still need the bin/local-cli script somewhere on your PATH.

One gotcha; if you still have the deprecated npm package installed, it usually sits earlier on your PATH and shadows the new command. The installer warns you about it. Get rid of it with npm uninstall -g @getflywheel/local-cli. You won’t miss it.

Local’s SSL “Trust” button is BROKEN on macOS. Here’s why, and here’s the fix. [A LocalWP Addon].

Click Trust next to your site’s SSL certificate in Local. Enter your admin password like a good citizen. Watch it report success. Open https://mysite.local and… “Your connection is not private”. Click Trust again. Password again. Success again. Warning again.

Insanity, as the saying goes, is clicking the same button twice and expecting different results. Or something like that.

The Problem

On modern macOS, Local’s Trust button doesn’t work. Well it does, but not for you. It shows the password prompt, appears to succeed, and changes absolutely nothing; browsers keep screaming about your .local certificate forever. And because it looks like it worked, you naturally assume the problem is elsewhere; your browser cache, your cert, your karma. It isn’t. It’s the button. Continue reading “Local’s SSL “Trust” button is BROKEN on macOS. Here’s why, and here’s the fix. [A LocalWP Addon].”

Sequel Pro can’t connect to Local’s MySQL 8? MySQL Fixes AddOn to the rescue [A LocalWP Addon].

The Problem

Connect a classic client (for example Sequel Pro, older Sequel Ace, older JDBC tools) to a Local site running MySQL 8 and you’re greeted with authentication errors about caching_sha2_password.

(I talked about this already, here)

The classic clients speak mysql_native_password; MySQL 8 defaults to the new plugin, and on 8.4+ the old plugin isn’t just non-default, but (and in my opinion, this is a bug of omission) it ships disabled.

Meanwhile Local’s own connections work fine, so from Local’s point of view there is no bug. From MY point of view, sitting in front of a client that can’t connect to my own database; there very much is. Continue reading “Sequel Pro can’t connect to Local’s MySQL 8? MySQL Fixes AddOn to the rescue [A LocalWP Addon].”

A quick note regarding MySQL error about caching_sha2_password.so not being able to be loaded

For local database manipulation I still use Sequel Pro. Why? Well, all the derivatives (Like Sequel Ace) have a smaller feature set, and alternatives (like MySQL WorkBench) are too complex, and even limited. (How hard is it to provide a socket based connection, or an SSH tunnel TCP connection…)

Anyhoo, a quick note to myself for fixing the error

Double-check that the socket path is correct and that you have the necessary privileges, and that the server is running.

MySQL said: Authentication plugin ‘caching_sha2_password’ cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 0x0002): tried: ‘/usr/local/mysql/lib/plugin/caching_sha2_password.so’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OS/usr/local/mysql/lib/plugin/caching_sha2_password.so’ (no such file), ‘/usr/local/mysql/lib/plugin/caching_sha2_password.so’ (no such file) Continue reading “A quick note regarding MySQL error about caching_sha2_password.so not being able to be loaded”

New toy – almost done – FluxEngine – stand-alone

Hello all.

Yes, I know. It’s been a long time since my last post, but I have a good reason. I have been busy, very very busy with a new 3D project.

Base on the fantastic work of David Given (https://cowlark.com) on FluxEngine I am in the process of developing a stand-alone device to read/write floppydisks (both 5,25 and 3,5 inch) to/from disk images. Please see David’s website on FluxEngine for more information on this part of the project.

You would say that the FluxEngine is the most difficult part made easy by David, and yes, that is true. What I am bringing to the party is the housing, fully 3D printed, the electronics to make it stand-alone, power supply, cooling etc. Interested? Please read on :)

Continue reading “New toy – almost done – FluxEngine – stand-alone”

This just in: Contact-Form-7 (WordPress) Vulnerability – 5 million websites at risk – CVE-2020-35489

A vulnerability has been discovered in Contact Form 7 that allows an attacker to upload malicious scripts. The publishers of Contact Form 7 have released an update to fix the vulnerability.

Unrestricted File Upload Vulnerability…

Noooo, I’m not going to steal/copy/plagiarize this article, just read the article on CVE 2020 35489 on searchenginejournal.com.

But I do have something to add. Continue reading “This just in: Contact-Form-7 (WordPress) Vulnerability – 5 million websites at risk – CVE-2020-35489”

Migrating from SVN to GIT. It has been done before, …, but has it?

Recent changes in policy re-ignited our quest to migrate away from Subversion to GIT, as GIT is much more powerful for branching and merging e.t.c.

Migrating from Subversion is not very hard; you just start over, right? So you want to lose all the project history? I don’t think so.

The migrated GIT-repository should include all history, all commit messages, all tags, all branches. How do you do that? Continue reading “Migrating from SVN to GIT. It has been done before, …, but has it?”

Handy script: lbf

[Edit: This script is defunct since Local rebuilt the application and ditched the virtual machine. This script works only with the old “Local by Flywheel”  and not with the “Local Lightning” app. For the latter, see my lbl script]

Local (by Flywheel) is great, but for a terminal type of person as I am, I find it way more convenient to SSH into a VM and use the WP-CLI to perform WordPress tasks. With a platform like Vagrant, one has the

vagrant ssh
command to shell into the virtual environment.

With Local, you can do this with the push of a button in Local, but as said, I like the terminal better.

lbf ssh
is waaaaay faster than going to the Local app, find the site, click the SSH button.

But wait, there is much more ;) Continue reading “Handy script: lbf”

macOS High Sierra, the magnificent update that killed the development environment.

[UPDATED sep 26]
[UPDATED again on oct 27th, see tags UPDATE2]

macOS High Sierra is awesome, but unfortunately, it killed my “old style” development environment. It was not just High Sierra; brew upgrade also had a big part in the failing of the development setup, if not ALL of it. I brew upgraded my set-up on Sierra (not High yet) and it got F’ed up as well. My guess; 95% Brew’s fault, 5% High Sierra (and only because High Sierra sort of forced me to brew upgrade)

If you are still using the “old” way for development websites (a.k.a., using macOSs own apache2 and brew php), you might want to wait with upgrading to High Sierra; I don’t have a working solution yet.

[UPDATE2] I think I might have a solution :)

Continue reading “macOS High Sierra, the magnificent update that killed the development environment.”

Synology NAS software on non-Synology hardware

I am the proud owner of a Synology DS1512+. She’s getting old but she’s still one of my more sensible purchases. The hardware quality and ease-of-use of the Synology Disk Manager (DSM) still pleases me every day.

I need my NAS to be operational. I use it for all my important stuff but I also have the “urge” to develop my own tools for it. I need a platform to develop software on, without the risk of losing any of my data.

Recently I found XPEnology. Is it a Synology DSM clone? No. It IS the original Synology DSM, without alterations. You just need something to boot it with; a bootloader. Is it legal???? I’m not sure. And when in doubt, go for safe; consider it illegal.

In retrospect, setting-up a XPEnology NAS is surprisingly easy. But for most tutorials you need a Windows computer (windows-only software is used). But on a Mac, you don’t need (most of this) 3rd party software. You have a Mac! A Mac comes with tools, but what tool to use and how?

Continue reading “Synology NAS software on non-Synology hardware”

Confidental Infomation
stop spam mail