【问题标题】:wp-cli works in windows cmd, but not in Gitbashwp-cli 适用于 windows cmd,但不适用于 Gitbash
【发布时间】:2018-01-01 15:30:07
【问题描述】:

我已经使用 Git-bash 安装了 wp-cli,创建了相关的 PATH 变量。

我现在可以在 Windows CMD 中输入“wp”并且它可以工作,但 Git-bash 无法识别该命令。

我必须做些什么才能让它与 Git-bash 一起使用,为什么它不能开箱即用?

【问题讨论】:

    标签: cmd git-bash wp-cli


    【解决方案1】:

    我遇到了同样的问题。例如,命令“wp cli version”在 cmd 中有效,但在 cygwin 中无效。

    查看以下教程:https://deluxeblogtips.com/install-wp-cli-windows/

    如果您使用的是 cygwin,您将需要创建另一个 wp 文件(不带 .bat)扩展名。只需将其命名为 wp,内容如下:

    #!/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" "$@"
    

    【讨论】:

      猜你喜欢
      • 2019-12-03
      • 2017-01-04
      • 2016-03-06
      • 1970-01-01
      • 2011-09-09
      • 2016-07-27
      • 2012-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多