Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phar file not executable from vendor/bin #5447

Closed
Wulfheart opened this issue Jul 17, 2023 · 10 comments · Fixed by composer/composer#11562
Closed

Phar file not executable from vendor/bin #5447

Wulfheart opened this issue Jul 17, 2023 · 10 comments · Fixed by composer/composer#11562

Comments

@Wulfheart
Copy link

When the phpunit.phar is distributed via composer in the vendor/bin folder then no output is shown.

I would prefer to use it that way in my projects as it then has the benefit that I don't have many dev dependencies I would only need for phpunit and I have the benefit of not having to download the phar each time.

In the issue composer/composer#11555 the problem got narrowed down to the following snippet:

if (__FILE__ === realpath($_SERVER['SCRIPT_NAME'])) {
$execute = true;
} else {
$execute = false;
}

After looking into it I saw that it was related to some bugs in the process isolation.

Related issues I found:

As far as I understand v10 was a major rewrite. Is it now possible to support the distribution via a bin directory?

@sebastianbergmann sebastianbergmann added status/waiting-for-feedback Waiting for feedback from original reporter installation/phar labels Jul 17, 2023
@sebastianbergmann
Copy link
Owner

When the phpunit.phar is distributed via composer in the vendor/bin folder then no output is shown.

We do not distribute PHPUnit's PHAR via Composer, so I am not sure I understand what you are trying to report.

PHPUnit's PHAR should not care about where it is located. I am not able to reproduce a problem when it is located in vendor/bin/phpunit:

$ ls -lh vendor/bin/phpunit 
-rwxr-xr-x. 1 sb sb 4.5M Jul 17 14:10 vendor/bin/phpunit
$ ./vendor/bin/phpunit --version
PHPUnit 10.2.6 by Sebastian Bergmann and contributors.

@Wulfheart
Copy link
Author

Thanks for your response.
I wanted to distribute the phar as part of a "quality tools"-package. For reproduction purposes you can use this package with composer require --dev wulfheart/phpunit-shim. If you execute vendor/bin/phpunit.phar then no output will be shown. However, if you execute vendor/wulfheart/phpunit-shim/phpunit.phar then it works fine.

@sebastianbergmann
Copy link
Owner

Can this issue be closed now that composer/composer#11562 has been implemented?

@ghostwriter
Copy link
Contributor

ghostwriter commented Aug 21, 2023

I was able to get around this issue by executing the Phar directly vendor/ghostwriter/coding-standard/tools/phpunit instead of vendor/bin/phpunit (linked via Composer less thanv2.6 [currently unreleased])

References: https://github.com/ghostwriter/coding-standard/blob/main/composer.json#L36-L47

@Wulfheart
Copy link
Author

That’s also my current hack/workaround.

@fredden
Copy link

fredden commented Sep 1, 2023

Composer version 2.6.0 has now been released, which includes the fix from composer/composer#11562. I think this issue can now be safely closed.

@ghostwriter
Copy link
Contributor

ghostwriter commented Sep 1, 2023

Thanks for the update and providing the fix. @fredden

@Seldaek
Copy link
Contributor

Seldaek commented Sep 3, 2023

Sorry @sebastianbergmann but it seems like our fix in Composer caused further issues (composer/composer#11615) as the file still shows up in the backtraces but the last entry in the backtrace doesn't match $_SERVER['SCRIPT_NAME'] I imagine that's the root cause of the issue anyway.. So I'm wondering if we should revert or if this can be fixed in PHPUnit or what to do..

@sebastianbergmann
Copy link
Owner

I might consider a pull request, but I will not look into this issue myself as installing PHPUnit's PHAR via Composer is not a supported installation method.

@Seldaek
Copy link
Contributor

Seldaek commented Sep 3, 2023

Ok I see.. my bad for trying to make things play nicer together I guess :D Happy to just revert, but I am curious to fully understand the problem first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants