scaffold-package-command icon indicating copy to clipboard operation
scaffold-package-command copied to clipboard

Fatal error: `react/promise` declaration when running command

Open BrianHenryIE opened this issue 1 year ago • 2 comments

Bug Report

Describe the current, buggy behavior

% wp scaffold package rocket/info

Success: Created package files in /Users/brianhenry/.wp-cli/packages/local/rocket/info
Success: Created package test files.
Success: Created package readme.
Success: Created package GitHub configuration.
Installing package rocket/info (dev-main || dev-master || dev-trunk)
Updating /Users/brianhenry/.wp-cli/packages/composer.json to require the package...
Registering /Users/brianhenry/.wp-cli/packages/local/rocket/info as a path repository...
Using Composer to install the package...
---
Loading composer repositories with package information
PHP Fatal error:  Declaration of React\Promise\Internal\FulfilledPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null): React\Promise\PromiseInterface must be compatible with React\Promise\PromiseInterface::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) in /Users/brianhenry/.wp-cli/packages/vendor/react/promise/src/Internal/FulfilledPromise.php on line 37

Fatal error: Declaration of React\Promise\Internal\FulfilledPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null): React\Promise\PromiseInterface must be compatible with React\Promise\PromiseInterface::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) in /Users/brianhenry/.wp-cli/packages/vendor/react/promise/src/Internal/FulfilledPromise.php on line 37

Describe how other contributors can replicate this bug

cat ~/.wp-cli/packages/composer.json 
{
    "name": "wp-cli/wp-cli",
    "description": "Installed community packages used by WP-CLI",
    "version": "2.11.0",
    "authors": [
        {
            "name": "WP-CLI",
            "email": "[email protected]"
        }
    ],
    "homepage": "https://wp-cli.org/package-index/",
    "require": {
        "wp-cli/dist-archive-command": "@stable",
        "wp-cli/scaffold-package-command": "dev-main || dev-master || dev-trunk"
    },
    "require-dev": {},
    "minimum-stability": "dev",
    "prefer-stable": true,
    "license": "MIT",
    "repositories": {
        "wp-cli": {
            "type": "composer",
            "url": "https://wp-cli.org/package-index/"
        }
    },
    "config": {
        "secure-http": true
    }
}

Also tried with @stable

Describe what you would expect as the correct outcome

Let us know what environment you are running this on

OS:	Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103 arm64
Shell:	/bin/zsh
PHP binary:	/opt/homebrew/Cellar/[email protected]/7.4.33_6/bin/php
PHP version:	7.4.33
php.ini used:	/opt/homebrew/etc/php/7.4/php.ini
MySQL binary:	/opt/homebrew/bin/mysql
MySQL version:	mysql from 11.3.2-MariaDB, client 15.2 for osx10.19 (arm64) using  EditLine wrapper
SQL modes:	STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
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:	/Users/brianhenry/.wp-cli/packages
WP-CLI packages dir:	/Users/brianhenry/.wp-cli/packages/
WP-CLI cache dir:	/Users/brianhenry/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.11.0

Provide a possible solution

Maybe the required package is locked and a bugfix version is available?

Provide additional context/Screenshots

Same issue under PHP 8.3 and 7.4 and on another machine.

BrianHenryIE avatar Sep 17 '24 18:09 BrianHenryIE

@BrianHenryIE Seems to work fine for me:

$ wp scaffold package rocket/info
Success: Created package files in /Users/danielbachhuber/wp-cli/packages/local/rocket/info
Success: Created package test files.
Success: Created package readme.
Success: Created package GitHub configuration.
Installing package rocket/info (dev-main || dev-master || dev-trunk)
Updating /Users/danielbachhuber/wp-cli/packages/composer.json to require the package...
Registering /Users/danielbachhuber/wp-cli/packages/local/rocket/info as a path repository...
Using Composer to install the package...
---
Loading composer repositories with package information
Built pool.
Running pool optimizer.
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Analyzed 101 packages to resolve dependencies
Analyzed 102 rules to resolve dependencies
Lock file operations: 1 install, 0 updates, 0 removals
Installs: rocket/info:dev-main
- Locking rocket/info (dev-main)
Writing lock file
Installing dependencies from lock file
Package operations: 1 install, 0 updates, 0 removals
Installs: rocket/info:dev-main
 - Installing <info>rocket/info</info> (<comment>dev-main</comment>)
Generating autoload files
No security vulnerability advisories found.
---
Success: Package installed.

I'm not sure how ReactPHP was added to the mix?

danielbachhuber avatar Oct 16 '24 13:10 danielbachhuber

I tested on another machine just now and had the same problem. Looks like the root is Composer itself requiring react/promise.

cat ~/.wp-cli/packages/composer.lock

..
{
            "name": "composer/composer",
            "version": "2.8.1",
            "source": {
                "type": "git",
                "url": "https://github.com/composer/composer.git",
                "reference": "e52b8672276cf436670cdd6bd5de4353740e83b2"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/composer/composer/zipball/e52b8672276cf436670cdd6bd5de4353740e83b2",
                "reference": "e52b8672276cf436670cdd6bd5de4353740e83b2",
                "shasum": ""
            },
            "require": {
                "composer/ca-bundle": "^1.5",
                "composer/class-map-generator": "^1.4.0",
                "composer/metadata-minifier": "^1.0",
                "composer/pcre": "^2.2 || ^3.2",
                "composer/semver": "^3.3",
                "composer/spdx-licenses": "^1.5.7",
                "composer/xdebug-handler": "^2.0.2 || ^3.0.3",
                "justinrainbow/json-schema": "^5.3",
                "php": "^7.2.5 || ^8.0",
                "psr/log": "^1.0 || ^2.0 || ^3.0",
                "react/promise": "^3.2",
                "seld/jsonlint": "^1.4",
                "seld/phar-utils": "^1.2",
                "seld/signal-handler": "^2.0",
                "symfony/console": "^5.4.35 || ^6.3.12 || ^7.0.3",
                "symfony/filesystem": "^5.4.35 || ^6.3.12 || ^7.0.3",
                "symfony/finder": "^5.4.35 || ^6.3.12 || ^7.0.3",
                "symfony/polyfill-php73": "^1.24",
                "symfony/polyfill-php80": "^1.24",
                "symfony/polyfill-php81": "^1.24",
                "symfony/process": "^5.4.35 || ^6.3.12 || ^7.0.3"
            },
...

Related: https://github.com/composer/composer/issues/11884 – [feature] Build and distribute scoped version of Composer https://github.com/wp-cli/wp-cli/issues/5920 – Conflict-free distribution - current state and issues that need solving

BrianHenryIE avatar Oct 16 '24 20:10 BrianHenryIE

came searching for the exact same issue.

❯ wp scaffold package rocket/info
Success: Created package files in /Users/gilzow/.wp-cli/packages/local/rocket/info
Success: Created package test files.
Success: Created package readme.
Success: Created package GitHub configuration.
Installing package rocket/info (dev-main || dev-master || dev-trunk)
Updating /Users/gilzow/.wp-cli/packages/composer.json to require the package...
Registering /Users/gilzow/.wp-cli/packages/local/rocket/info as a path repository...
Using Composer to install the package...
---
Loading composer repositories with package information
PHP Fatal error:  Declaration of React\Promise\Internal\FulfilledPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null): React\Promise\PromiseInterface must be compatible with React\Promise\PromiseInterface::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) in /Users/gilzow/.wp-cli/packages/vendor/react/promise/src/Internal/FulfilledPromise.php on line 37

Fatal error: Declaration of React\Promise\Internal\FulfilledPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null): React\Promise\PromiseInterface must be compatible with React\Promise\PromiseInterface::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) in /Users/gilzow/.wp-cli/packages/vendor/react/promise/src/Internal/FulfilledPromise.php on line 37
Reverted composer.json.
❯ cat ~/.wp-cli/packages/composer.json
{
    "name": "wp-cli/wp-cli",
    "description": "Installed community packages used by WP-CLI",
    "version": "2.11.0",
    "authors": [
        {
            "name": "WP-CLI",
            "email": "[email protected]"
        }
    ],
    "homepage": "https://wp-cli.org/package-index/",
    "require": {
        "wp-cli/scaffold-package-command": "@stable"
    },
    "require-dev": {},
    "minimum-stability": "dev",
    "prefer-stable": true,
    "license": "MIT",
    "repositories": {
        "wp-cli": {
            "type": "composer",
            "url": "https://wp-cli.org/package-index/"
        }
    },
    "config": {
        "secure-http": true
    }
}

gilzow avatar Nov 05 '24 21:11 gilzow

I'm experiencing the same issue.

 wp scaffold package test/test
Success: Created package files in /Users/timothybjacobs/.wp-cli/packages/local/test/test
Success: Created package test files.
Success: Created package readme.
Success: Created package GitHub configuration.
Installing package test/test (dev-main || dev-master || dev-trunk)
Updating /Users/timothybjacobs/.wp-cli/packages/composer.json to require the package...
Registering /Users/timothybjacobs/.wp-cli/packages/local/test/test as a path repository...
Using Composer to install the package...
---
Loading composer repositories with package information

Fatal error: Declaration of React\Promise\Internal\FulfilledPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null): React\Promise\PromiseInterface must be compatible with React\Promise\PromiseInterface::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) in /Users/timothybjacobs/.wp-cli/packages/vendor/react/promise/src/Internal/FulfilledPromise.php on line 37
Reverted composer.json.
wp cli info
OS:	Darwin 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000 arm64
Shell:	/bin/bash
PHP binary:	/Users/timothybjacobs/Library/Application Support/Herd/bin/php82
PHP version:	8.2.28
php.ini used:
MySQL binary:	/Users/timothybjacobs/Library/Application Support/Herd/bin//mysql
MySQL version:	mysql  Ver 8.0.36 for macos14 on arm64 (MySQL Community Server - GPL)
SQL modes:
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:	phar:///usr/local/bin/wp
WP-CLI packages dir:	/Users/timothybjacobs/.wp-cli/packages/
WP-CLI cache dir:	/Users/timothybjacobs/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	2.12.0

TimothyBJacobs avatar May 13 '25 19:05 TimothyBJacobs