phpDocumentor: Phar doesn't work after 3.3.1
Running the phpDocumentor phar worked fine for me up to 3.3.1 but it stopped working for 3.4.0. This cropped up initially in a gitlab pipeline, it had worked fine on Aug 15 but it stopped working Aug 16. Nothing in the pipeline environment changed between runs. I was also able to replicate the issue on my personal machine.
Expected behavior
Running the phpDocumentor phar file should work.
$ curl -L https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.3.1/phpDocumentor.phar > phpdoc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 22.0M 100 22.0M 0 0 19.2M 0 0:00:01 0:00:01 --:--:-- 23.8M
$ chmod +x phpdoc
$ ./phpdoc
phpDocumentor v3.3.1
Parsing files
129/129 [============================] 100%
Applying transformations (can take a while)
4/4 [============================] 100%
All done in 1 seconds!
Actual behavior
The phpDocumentor phar complains about Failed to open stream: phar error: no directory in "phar:///[redacted]/phpdoc/bin/phpdoc"
$ curl -L https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.0/phpDocumentor.phar > phpdoc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 14.4M 100 14.4M 0 0 9093k 0 0:00:01 0:00:01 --:--:-- 13.5M
$ chmod +x phpdoc
$ ./phpdoc
PHP Warning: require(phar:///[redacted]/phpdoc/bin/phpdoc): Failed to open stream: phar error: no directory in "phar:///[redacted]/phpdoc/bin/phpdoc", must have at least phar:///[redacted]/phpdoc/bin/phpdoc/ for root directory (always use full p
ath to a new phar) in /[redacted]/phpdoc on line 10
PHP Fatal error: Uncaught Error: Failed opening required 'phar:///[redacted]/phpdoc/bin/phpdoc' (include_path='.:') in [redacted]/phpdoc:10
Stack trace:
#0 {main}
thrown in /[redacted]/phpdoc on line 10
Steps to reproduce the problem
- Download phar
- Set executable flag
- Run the phar file
Your environment
- Version used: 3.4.0
- Install method: phar
- PHP version: 8.2.9 and 8.1.14
- Operating system and version: Arch Linux and Ubuntu 20.04.5 LTS
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 2
- Comments: 19 (11 by maintainers)
Commits related to this issue
- fix phpdoc version seems like there is an issue with 3.4 for now https://github.com/phpDocumentor/phpDocumentor/issues/3562 — committed to elabftw/elabftw by MarcelBolten 10 months ago
- Fix: allow renaming of the phar release By using phar::mapPhar we allow the current phar to be renamed while files can still be loaded by it's orginal name. Fixes #3562 — committed to phpDocumentor/phpDocumentor by jaapio 10 months ago
- Codecoverage for cypress tests (#4555) * add php codecoverage to cypress tests * escape double less than * fix phpdoc version seems like there is an issue with 3.4 for now https://github.com/... — committed to elabftw/elabftw by MarcelBolten 10 months ago
- Fix: allow renaming of the phar release By using phar::mapPhar we allow the current phar to be renamed while files can still be loaded by it's orginal name. Fixes #3562 — committed to johanneskonst/phpDocumentor by jaapio 10 months ago
v3.4.1 willl be available within minutes. This should fix your issue.
Thanks for all the reports!
php 7.4 is not supported anymore.
I created a new issue, please continue there, as this issue was different.
Hi@all, I’m facing a similar problem, but only the second time I run the phar.
My environment
Steps to reproduce the problem:
FYI: I’m working into /tmp directory.
$ wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.1/phpDocumentor.phar$ chmod +x phpDocumentor.phar$ ./phpDocumentor help(help command, for instance)After these steps. from the second time I launch the phar onwards:
$ ./phpDocumentor helpI obtain the following result:
Additionally I’ve extracted the phar before and after running it and seen that in the second extraction there are missing files. One for all
phar://phpDocumentor.phar/bin/phpdocI think the problem you are facing is caused by the fact the new release is a zipped phar file to reduce the size of the package. When I download the file using your curl command I get the same error however when I use the original file file it still works.
Making a symlink does work, that might help you to solve your issue with to much impact.
It’s unclear to me right now why this happens, I will investigate this.