Skip to content

phpunit-bridge: Doesn't work properly with vendor being a symlink #44863

Open
@glensc

Description

@glensc

Symfony version(s) affected

<=6.0.0

Description

When ./vendor is a symlink, simple-phpunit emits some warning and then installs PHPUnit to ./phpunit-8.5-0 every time being invoked.

$ ./vendor/bin/simple-phpunit tests/EncoderSelectionTest.php
PHP Warning:  chdir(): No such file or directory (errno 2) in /Users/glen/Library/Caches/glen/composer/dvideo-admin/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php on line 178

Warning: chdir(): No such file or directory (errno 2) in /Users/glen/Library/Caches/glen/composer/dvideo-admin/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php on line 178
The "hirak/prestissimo" plugin (installed globally) was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.1.0"). You may need to run composer update with the "--no-plugins" option.
Creating a "phpunit/phpunit" project at "./phpunit-8.5-0"
                                                                       Installing phpunit/phpunit (8.5.22)
Plugins have been disabled.
  - Installing phpunit/phpunit (8.5.22): Extracting archive
Created project in /Users/glen/OneDrive - Foo Ltd/scm/dvideo/dvideo-admin/phpunit-8.5-0
...

How to reproduce

composer require symfony/phpunit-bridge --dev
mv vendor /tmp
ln -s /tmp/vendor
./vendor/bin/simple-phpunit
./vendor/bin/simple-phpunit

Possible Solution

Fall back to use getcwd()/composer.json if dirname() traversal fails. At least fix bug that PHPUnit is installed every invocation.

Additional Context

I keep my working dirs in OneDrive, excluding vendor. OneDrive doesn't support excluding filenames or directories from sync, hence the symlink hack.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions