WP-CLI vs custom environments

Hi, not my first post about WP-CLI in addons here. But there has been no traction on the other topics. And now I’ve given it another go.

I am fully able to utilize WP-CLI in the addon, doing things like:

LocalMain.addIpcAsyncListener('mainWpCli', (args) => serviceContainer.wpCli.run(siteData.getSite(args.siteId), args.command));

Just testing with a command that does ['plugin', 'list'] like this:
const command = ['plugin', 'list']; const searchReplace = ipcAsync('mainWpCli', { 'siteId': props.id, command: command }); searchReplace.then(....

This works fine for regular WordPress installations. But for composer based WordPress installations, or anything non default I guess (maybe the issue is due to the wp-config.php using dotenv?). This gives an error:
The ipcAsync call to channel 'mainWpCli' was rejected with the main thread error: undefined

Check out the error props {channel, channelArgs, messageMain, stackMain} for more details.

So I’ve been trying to dig into this with no success. And I can’t figure out what you mean with “Check out the error props…”. Where can I check the error props?

FYI. Running wp-cli commands in terminal on a site with this setup works fine

1 Like

Btw. I found that you listen to wpCli:run. As an aside, instead of setting up my own IpcAsyncListener, could I just use ipcAsync('wpCli:run', props.id, command);?