admin管理员组

文章数量:1279175

I have tried to install Wordpress CLI on my windows machine running windows 10. But for some reason everytime i try to run the

wp

Command it says

'sh' is not recognized as an internal or external command,operable program or batch file. 

I have tried multiple times to reinstall it and set it up from scratch with different guides but it just won't work.

This is what the bat file says

@ECHO OFF
SET BIN_TARGET=%~dp0/./wp-cli.phar
php "%BIN_TARGET%" %*

This is the environment variable i am using to point it to the bat file

That is where the .phar file and my .bat file are located to run the CLI.

All help is appreciated

Regards

Jonas Bang

I have tried to install Wordpress CLI on my windows machine running windows 10. But for some reason everytime i try to run the

wp

Command it says

'sh' is not recognized as an internal or external command,operable program or batch file. 

I have tried multiple times to reinstall it and set it up from scratch with different guides but it just won't work.

This is what the bat file says

@ECHO OFF
SET BIN_TARGET=%~dp0/./wp-cli.phar
php "%BIN_TARGET%" %*

This is the environment variable i am using to point it to the bat file

That is where the .phar file and my .bat file are located to run the CLI.

All help is appreciated

Regards

Jonas Bang

Share Improve this question asked Sep 28, 2021 at 9:12 Jonas BangJonas Bang 133 bronze badges 2
  • 1 Where did the .bat come from? I'm surprised they gave you one if it then needs sh. But it looks you'll need a unix-like environment for your Windows e.g. Git bash or WSL2. Note however the homepage says "limited support in Windows environment" – Rup Commented Sep 28, 2021 at 9:51
  • have you attempted the official windows install method at make.wordpress/cli/handbook/guides/installing/…? Note that WP CLI has limited compatibility on a Windows non-Unix environment. You would be better off with a containerised/virtual environment that provides Linux, such as WSL or perhaps even git bash – Tom J Nowell Commented Sep 28, 2021 at 9:57
Add a comment  | 

1 Answer 1

Reset to default 1

Currently i have several process running in my CI/CD with wp-cli and all works fine in windows and unix. In my experience this is your best option in windows:

#1 Add PHP to your Windows Path Variable

#2 Install, as @Rup suggests, Git-bash terminal.

#3 Execute an wp-cli command like that:

vendor/bin/wp cache flush --path=public/wp-cms/wp-core

*This code consider you are using wp-cli managed with composer, and the files are locatted at vendor folder, otherwise you can replace vendor/bin/wp with wp

本文标签: wp cliWP Cli will not execute on Windows