If you use Local by Flywheel for WordPress development and have encountered issues with WP-CLI, particularly missing Action Scheduler commands, this guide will walk you through the fix.


🔍 The Problem

  • WP-CLI inside Local is outdated or missing commands.
  • wp action-scheduler list does not exist.
  • Local’s PHP setup throws Xdebug, opcache, and Imagick errors.
  • WP-CLI fails to update properly due to Local’s internal structure.

🛠 The Solution: Manually Updating WP-CLI in Local

Since Local manages its own WP-CLI version, we need to manually replace it with the latest version and ensure it recognizes Action Scheduler commands.


🔹 Step 1: Download the Latest WP-CLI

Open your Mac terminal and run:

cd ~/Desktop
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

This downloads the latest WP-CLI to your desktop.

🔹 Step 2: Fix Permissions

sudo chown -R $(whoami):admin ~/Desktop/wp-cli.phar
sudo chmod +x ~/Desktop/wp-cli.phar

This ensures WP-CLI is executable and owned by your user.

🔹 Step 3: Replace WP-CLI in Local

Since Local keeps its own WP-CLI version, we need to overwrite it:

sudo cp -pR ~/Desktop/wp-cli.phar /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar

This replaces the default Local WP-CLI binary.

🔹 Step 4: Remove macOS Quarantine Attributes

macOS may block the file from running, so we need to remove restrictions:

sudo xattr -d -rs com.apple.quarantine /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar
sudo xattr -d -rs com.apple.provenance /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar

🔹 Step 5: Create a System-wide Symlink (Optional)

If you want WP-CLI to work globally, link it to /usr/local/bin/:

sudo ln -sf /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar /usr/local/bin/wp

🔹 Step 6: Verify WP-CLI Installation

Check if WP-CLI is correctly installed by running:

wp cli version

And verify Local is using the updated WP-CLI:

which wp

Expected output:

/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar

✅ Step 7: Test Action Scheduler in WP-CLI

Now that WP-CLI is fixed, check if Action Scheduler is working:

wp action-scheduler status

If you see system info for Action Scheduler, it’s working! 🎉

To list scheduled actions, use:

wp action-scheduler action list --format=table

🔹 Optional: Delete or Cancel Scheduled Actions

Cancel All Pending Actions

wp action-scheduler action cancel --all

Delete All Actions

wp action-scheduler action delete $(wp action-scheduler action list --field=id)

⚠️ This deletes all scheduled actions. Use with caution.


🚀 Final Step: Restart Local and Test Again

After making changes, restart Local by Flywheel and test WP-CLI again:

wp action-scheduler status
wp action-scheduler action list

If everything works, you’ve successfully fixed WP-CLI inside Local by Flywheel and enabled Action Scheduler commands. 🎉


Troubleshooting

1️⃣ WP-CLI Still Shows an Old Version?

Try reloading your terminal:

source ~/.zshrc

Or, remove any old WP-CLI binary manually:

sudo rm -f /usr/local/bin/wp

Then re-run:

which wp

2️⃣ WP-CLI Still Missing Action Scheduler Commands?

Try reinstalling the plugin:

wp plugin deactivate action-scheduler --force
wp plugin delete action-scheduler
wp plugin install action-scheduler --activate

Then retry:

wp action-scheduler action list

3️⃣ Still Getting PHP Errors?

Local may be using a broken PHP version. Try switching to PHP 8.0 inside Local’s settings.

Or, manually disable problem extensions:

mv "/Users/$(whoami)/Library/Application Support/Local/lightning-services/php-8.2*/bin/darwin/lib/php/extensions/no-debug-non-zts-*/opcache.so" ~/Desktop/

Then restart Local and try WP-CLI again.


🎯 Conclusion

By following these steps, you’ve: ✅ Updated WP-CLI inside Local by Flywheel. ✅ Enabled missing Action Scheduler commands. ✅ Fixed Local’s PHP issues and ensured WP-CLI works correctly.

You’re now ready to manage WooCommerce scheduled actions via WP-CLI! 🚀

Let me know in the comments if you have any questions or need further help!