Skip to content

Composer autoloader misses dependencies on Windows in cli container #52291

@ZachWatkins

Description

@ZachWatkins

Description

When I run wp-env run cli --env-cwd=wp-content/themes/wordpress-theme composer dumpautoload from Powershell on Windows 11, it builds an incomplete class list in vendor/composer/autoload_classmap.php and an exception is thrown due to a missing class when I run wp-env run cli --env-cwd=wp-content/themes/wordpress-theme ./vendor/bin/pest.

Output:

Generating optimized autoload files (authoritative)
Generated optimized autoload files (authoritative) containing 2002 classes

Test Exception:

ERROR  Class "PHPUnit\Metadata\Parser\Registry" not found
Location: /var/www/html/wp-content/themes/wordpress-theme/vendor/phpunit/phpunit/src/Util/Test.php:31   

When I run wp-env run wordpress --env-cwd=wp-content/themes/wordpress-theme composer dumpautoload from Powershell on Windows 11, the class list is complete and I am able to run wp-env run cli --env-cwd=wp-content/themes/wordpress-theme ./vendor/bin/pest with passing tests.

Output:

Generating optimized autoload files (authoritative)
Generated optimized autoload files (authoritative) containing 2109 classes

Test Success:

PASS  Tests\Feature\ExampleTest
 ✓ example                                                                                      0.56s  

PASS  Tests\Unit\ExampleTest
 ✓ example                                                                                      0.15s  

Tests:    2 passed (2 assertions)
Duration: 4.63s

My repo is here: https://github.com/ZachWatkins/wordpress-theme

Step-by-step reproduction instructions

  1. On Windows 11 (and presumably 10), open Powershell.
  2. Clone the repo: git clone https://github.com/ZachWatkins/wordpress-theme
  3. Switch to the repo's directory: cd wordpress-theme
  4. If using NVM and not using Node version 18.16.1, then switch to that Node version: nvm use
  5. Install NPM dependencies: npm install
  6. Start Docker Desktop
  7. Start the wp-env package's Docker containers: npm start
  8. Install Composer dependencies using the cli environment: npm run wp-env run cli -- --env-cwd=wp-content/themes/wordpress-theme composer install
  9. Run the tests: npm run wp-env run cli -- --env-cwd=wp-content/themes/wordpress-theme ./vendor/bin/pest

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Tool] Env/packages/env[Type] Help RequestHelp with setup, implementation, or "How do I?" questions.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions