Error running wp-cli commands with Sage 10 theme

Hi there,

Having some difficulties running wp-cli commands with a Sage 10 theme.

When I run wp [command], I get this error:

In Application.php line 211:

  Declaration of Illuminate\Console\Application::add(Symfony\Component\Console\Command\Command $command) must be compatible with Symfony\Component\Cons
  ole\Application::add(Symfony\Component\Console\Command\Command $command): ?Symfony\Component\Console\Command\Command

When I run wp [command] --skip-theme I don’t see the error.

Any idea what I can try to fix this or at least isolate the problem?

Thanks!

For a bit of context, this is in my composer.json in the project root:

"require": {
    "php": ">=8.0",
    "composer/installers": "^2.2",
    "vlucas/phpdotenv": "^5.5",
    "oscarotero/env": "^2.1",
    "roots/bedrock-autoloader": "^1.0",
    "roots/bedrock-disallow-indexing": "^2.0",
    "roots/wordpress": "6.7.1",
    "roots/wp-config": "1.0.0",
    "roots/wp-password-bcrypt": "1.2.0",
    "roots/acorn": "^4.3"
  },

And this is in my theme composer.json:

"require": {
    "php": ">=8.1",
    "log1x/acf-composer": "^3.2",
    "log1x/poet": "^2.1",
    "log1x/sage-directives": "^2.0",
    "mwdelaney/sage-advanced-custom-fields": "^1.6"
  },
  "require-dev": {
    "laravel/pint": "^1.13"
  },

And the output of wp --info is:

OS:	Darwin 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020 x86_64
Shell:	/bin/zsh
PHP binary:	/Users/magenta/.indigo/stacks/371B0C/php_8E4F/bin/php
PHP version:	8.3.12
php.ini used:	/Users/magenta/.indigo/stacks/371B0C/php_8E4F/etc/php.ini
MySQL binary:	/Users/magenta/.indigo/stacks/371B0C/mysql_BBD8/bin/mysql
MySQL version:	mysql  Ver 8.3.0 for macos12.7 on x86_64 (Homebrew)
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:	/Users/magenta/Dev/meaa
WP-CLI packages dir:	
WP-CLI cache dir:	/Users/magenta/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	/Users/magenta/Dev/meaa/wp-cli.yml
WP-CLI version:	2.11.0

I’d start out by putting my dependencies in the same place.

You have Acorn installed from Bedrock’s composer.json, while your theme has Acorn specific packages in its composer.json file.

Either move the roots/acorn dependency to your theme, or move your theme deps to Bedrock.

Since you’re using Bedrock, I’d recommend keeping them all in the root instead of the theme.

Ok, will do.

Do I still need composer in the theme, or can all the deps be handled at the root layer and autoloaded by the theme?

And should I move these parts to the root?

"extra": {
    "acorn": {
      "providers": [
        "App\\Providers\\ThemeServiceProvider"
      ]
    }
  },
"psr-4": {
    "App\\": "app"
  },

Thanks!