crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.33k stars 233 forks source link

Build micro error when using require #476

Closed joelwurtz closed 5 months ago

joelwurtz commented 5 months ago

Not sure what changed, but since a few days when we try to build micro and adding a phar to it does not work anymore, we go those kind of errors:

...

Warning: require(): Seek on self stream failed in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/autoload_real.php on line 42

Warning: include(): Seek on self stream failed in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php on line 576

Warning: include(): Seek on self stream failed in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php on line 576

Warning: include(): Seek on self stream failed in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php on line 576

Fatal error: Uncaught ErrorException: Warning: include(): Seek on self stream failed in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php:576
Stack trace:
#0 phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php(576): include()
#1 phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('phar:///home/jo...')
#2 phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/symfony/error-handler/ErrorHandler.php(498): Composer\Autoload\ClassLoader->loadClass('Symfony\\Compone...')
#3 [internal function]: Symfony\Component\ErrorHandler\ErrorHandler->handleException(Object(ErrorException))
#4 {main}
  thrown in phar:///home/joelwurtz/Workspace/Oss/castor/castor.linux-amd64/vendor/composer/ClassLoader.php on line 576

I try using different versions of SPC, use specific version of PHP and even checkout specific version of phpmicro but we keep having this failure, not sure where it fails here.

Do you have some inputs on how to debug this so we can fix this error ?

crazywhalecc commented 5 months ago

If the problem only occurs with a recent build, it may be related to a major version upgrade of phpmicro. Could you provide a minimal reproducible phar or a process for building a phar?

joelwurtz commented 5 months ago

With phar on this release : https://github.com/jolicode/castor/releases/tag/v0.17.1 i get the error

We execute those commands :

spc 'download' '--for-extensions=mbstring,phar,posix,tokenizer,pcntl,curl,filter,openssl' '--with-php=8.3'
spc 'build' 'mbstring,phar,posix,tokenizer,pcntl,curl,filter,openssl' '--build-micro' '--with-micro-fake-cli' '--arch=x86_64'
spc 'micro:combine' 'castor.linux-amd64.phar' '--output=castor.linux-amd64'
crazywhalecc commented 5 months ago

I just asked the author of phpmicro and debugged with him and found out that it should be a bug in phpmicro itself. We will fix it tomorrow.

crazywhalecc commented 5 months ago

phpmicro has fixed phar issue, remember cleaning buildroot and source, and bin/spc del-download micro && bin/spc download micro to download the latest micro repo to build.

joelwurtz commented 5 months ago

Thanks a lot <3, and also thanks to the author of phpmicro for its quick reaction.

It seems to be working with last SPC version, however older versions still have the bug, (i think this fork https://github.com/static-php/phpmicro should be updated in order to make it work on older versions)

crazywhalecc commented 5 months ago

I've updated static-php fork repo 👏

HallexCosta commented 5 months ago

@crazywhalecc This new phpmicro update resolved the initial error, but now I'm getting a new error. I followed the instructions to remove the buildroot and source folders bin/spc del-download micro && bin/spc download micro

However, when I try to run the binary with ./my-binary it shows the hyperf commands normally.image

Now if I try to run the server with the command ./my-binary start, it shows error logs image