wp-cli / scaffold-package-command

Scaffolds WP-CLI commands with functional tests, full README.md, and more.
MIT License
69 stars 20 forks source link

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

Open BrianHenryIE opened 2 months ago

BrianHenryIE commented 2 months ago

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": "noreply@wpcli.org"
        }
    ],
    "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/php@7.4/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.

danielbachhuber commented 1 month ago

@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?

BrianHenryIE commented 1 month ago

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

gilzow commented 2 weeks ago

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": "noreply@wpcli.org"
        }
    ],
    "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
    }
}