Skip to content

Fix group alias execution on Windows by passing $env to proc_open_compat#6221

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-ssh-error-alias-groups
Open

Fix group alias execution on Windows by passing $env to proc_open_compat#6221
Copilot wants to merge 2 commits intomainfrom
copilot/fix-ssh-error-alias-groups

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

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:

$full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$alias} ...";

Without the $env parameter, 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

  • Initialize $env = null before proc_open_compat() call
  • Pass $env as 5th parameter to enable Windows environment variable extraction
// Before
$proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes );

// After  
$env = null;
$proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes, null, $env );

The existing _proc_open_compat_win_env() function extracts WP_CLI_CONFIG_PATH=/path from 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
    • Triggering command: /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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>SSH error when using alias groups in remote commands</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

When I run a command against multiple aliases using the group alias @clients, I get the following error:
ssh is not recognized as an internal or external command, operable program or batch file. (see attachment)
error

The weird thing though is that when I run a command with just an regular alias, like wp @client_name core update, everything works fine. Besides, everything is just set up accordingly to the documentation in the config.yml file.

Describe what you expect as the correct outcome

The command should just run against all the listed aliased in the group @clients.

@clients:
  - @client1
  - @client2
  - @client3

(Paste the output of "wp cli info" into this box)

Shell:  C:\Program Files\Git\usr\bin\bash.exe
PHP binary:     C:\xampp\php\php.exe
PHP version:    7.3.2
php.ini used:   C:\xampp\php\php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       C:\Users\Pieter
WP-CLI packages dir:
WP-CLI global config:   C:\Users\Pieter/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.4.0```

</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 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.

@github-actions github-actions bot added bug command:cli Related to 'cli' command command:cli-alias Related to 'cli alias' command labels Feb 2, 2026
@codecov
Copy link

codecov bot commented Feb 2, 2026

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
Copilot AI requested a review from swissspidy February 2, 2026 03:50
@swissspidy swissspidy marked this pull request as ready for review February 2, 2026 04:01
@swissspidy swissspidy requested a review from a team as a code owner February 2, 2026 04:01
Copilot AI review requested due to automatic review settings February 2, 2026 04:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $env parameter to proc_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:cli Related to 'cli' command command:cli-alias Related to 'cli alias' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH error when using alias groups in remote commands

2 participants