I was trying to use WP-CLI from my terminal… using the new Windows Terminal app and the Linux Subsystem that is finally available and totally rocks. But from my normal command line commands like wp db prefix
don’t work because the command can’t connect to the DB that’s in the local container.
So I researched a little and found the feature where you can launch SSH from the Local UI. This lauches the crummy old school Windows Command Prompt (cmd.exe) though and I can’t run any custom commands. For example I have this activated in a plugin:
function kia_test_cli(){
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'test', 'kia_test_cli_command' );
}
}
add_action( 'plugins_loaded', 'kia_test_cli' );
function kia_test_cli_command() {
WP_CLI::runcommand( 'db prefix' );
}
But when I run wp test
in the cmd.exe console I get “Could not open input file C:\Program” It’s not clear exactly what file this is referencing but I’m guessing it’s stuck on windows naming system as “C:\Program Files” has a space in it.
So I either
- need the ability to change the terminal that “Open site shell” launches (Which would be a great option in Local since it’s a dev tool and even in windows there are finally some good options for terminals). Just found this Ability to change Windows SSH Client post so gonna try that next.
or
- need to know how to SSH into the container from another terminal. How does one find the IP address for the container.
or
- Advice on how to set up: https://github.com/bigwing/local-wp-cli which looks promising but I was unsure which the readme references.