Skip to content

rewrite structure seems broken on Windows #4566

@paulgibbs

Description

@paulgibbs

On Windows, wp rewrite structure --path=c:\inetpub\wwwroot '/%year%/%monthnum%/%postname%/' doesn't work; the permalinks aren't set. The failure is caused by https://github.com/wp-cli/rewrite-command/blob/6b1695887e289ffad14c8f4ea86b5f1d92757408/src/Rewrite_Command.php#L163

It might be due to how the command is invoked by WP_CLI::runcommand(). I believe the issue is something to do with spaces in folder names in Windows' %path% env. var. because the error message is:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

(On Windows, there's a folder called "C:\Program Files (x86)").
My %path% is:

C:\Program Files (x86)\PHP\v7.0;c:\projects\wordhat-tools;C:\Program Files\Java\ jdk1.8.0\bin;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Perl\site\bin;C:\Per l\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System3 2\WindowsPowerShell\v1.0\;C:\Program Files\7-Zip;C:\Program Files\Microsoft\Web Platform Installer\;C:\Tools\GitVersion;C:\Tools\PsTools;C:\Program Files\Git LF S;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Microsoft SQL Server\12 0\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Bi nn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files \Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\ 120\Tools\Binn\ManagementStudio\;C:\Tools\WebDriver;C:\Program Files (x86)\Micro soft SDKs\TypeScript\1.4\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Co mmon7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI\wbi n;C:\Ruby193\bin;C:\Tools\NUnit\bin;C:\Tools\xUnit;C:\Tools\MSpe;C:\Users\appvey or\AppData\Local\Yarn\bin;C:\Users\appveyor\AppData\Roaming\npm

The actual permalink passed to the command is irrelevant -- it can be junk, I'm fairly sure it's not Windows trying to parse %year% as a system environment variable of that name, etc.

I've only tested this on Appveyor.com -- which is a Windows CI environment -- so it's possible the issue is somehow specific to that environment, but I wanted to create an issue so maybe we can get a second opinion/more testing.

Log from a failed run: https://ci.appveyor.com/project/PaulGibbs/behat-wordpress-extension/build/debug-appveyor%20-%20402a303fca7909a4ef937f1282c1259c15333667
Appveyor config: https://github.com/paulgibbs/behat-wordpress-extension/blob/master/appveyor.yml

Other WP-CLI commands work fine, such as downloading/installing and creating content, users, and so on. WordPress itself also seems fine when accessed from a web browser.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions