wp-cli works in windows cmd, but not in Gitbash
Asked Answered
H

1

9

I've installed the wp-cli using Git-bash, created the relevant PATH variables.

I am now able type 'wp' into the Windows CMD and it works, but Git-bash doesn't recognize the command.

What must I do get this working with Git-bash, and why doesn't it work out of the box?

Hera answered 26/7, 2017 at 10:48 Comment(0)
M
17

I run into the same issue. For example command "wp cli version" is working in cmd but not in cygwin.

Check following tutorial: https://deluxeblogtips.com/install-wp-cli-windows/

If you are using cygwin, you will need to create another wp file (without .bat) extension. Just name it wp with following content:

#!/usr/bin/env sh

dir=$(d=${0%[/\\]*}; cd "$d"; pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
    # Cygwin paths start with /cygdrive/ which will break windows PHP,
    # so we need to translate the dir path to windows format. However
    # we could be using cygwin PHP which does not require this, so we
    # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
    if [[ $(which php) == /cygdrive/* ]]; then
        dir=$(cygpath -m $dir);
    fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/wp-cli.phar" "$@"
Musket answered 10/2, 2018 at 2:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.