diff --git a/php/boot-phar.php b/php/boot-phar.php index e5f94a262..a708cac62 100644 --- a/php/boot-phar.php +++ b/php/boot-phar.php @@ -9,9 +9,13 @@ die( -1 ); } -// Store the path to the Phar early on for `Utils\phar-safe-path()` function. -define( 'WP_CLI_PHAR_PATH', Phar::running( true ) ); +// Store the filesystem path for `Utils\phar_safe_path()` function. +// Using Phar::running(false) returns just the filesystem path without phar:// protocol. +// This prevents phar_safe_path() from attempting to replace "phar://phar://..." incorrectly. +define( 'WP_CLI_PHAR_PATH', Phar::running( false ) ); +// Use the phar alias 'wp-cli.phar' which is set during phar creation and works +// regardless of the actual filename. This ensures template paths resolve correctly. if ( file_exists( 'phar://wp-cli.phar/php/wp-cli.php' ) ) { define( 'WP_CLI_ROOT', 'phar://wp-cli.phar' ); include WP_CLI_ROOT . '/php/wp-cli.php';