Fix group alias execution on Windows by passing $env to proc_open_compat#6221
Open
Fix group alias execution on Windows by passing $env to proc_open_compat#6221
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SSH error when using alias groups in remote commands
Fix group alias execution on Windows by passing $env to proc_open_compat
Feb 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a Windows-specific bug where group aliases with SSH configurations fail with "ssh is not recognized as an internal or external command". The issue only affects group aliases; single aliases work correctly.
Changes:
- Modified
run_alias_group()to pass the$envparameter toproc_open_compat(), enabling Windows environment variable extraction from Unix-style command syntax
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Group aliases with SSH configurations fail on Windows with "ssh is not recognized as an internal or external command". Single aliases work correctly.
Root Cause
run_alias_group()spawns child processes with Unix-style environment variable syntax:Without the
$envparameter,proc_open_compat()cannot invoke_proc_open_compat_win_env()to extract and separate environment variables on Windows. Child processes fail to load the config file, breaking SSH alias resolution.Changes
php/WP_CLI/Runner.php
$env = nullbeforeproc_open_compat()call$envas 5th parameter to enable Windows environment variable extractionThe existing
_proc_open_compat_win_env()function extractsWP_CLI_CONFIG_PATH=/pathfrom the command string and populates$env['WP_CLI_CONFIG_PATH'], allowing Windows to properly set the environment for child processes.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php(dns block)nosuchhost_asdf_asdf_asdf.com/usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.