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

force-autodiscovery (enabled) and dump-autoload (disabled) are incompatible #1409

Open
llaville opened this issue Sep 7, 2024 · 0 comments

Comments

@llaville
Copy link
Contributor

llaville commented Sep 7, 2024

Bug report

Question Answer
Box version 4.6.2@29c3585
PHP version 8.2.23
Platform with version Ubuntu 22.04 LTS
Github Repo - https://github.com/llaville/sarif-php-converters/ (branch 1.0)
box.json
{
   "main": "report-converter",
   "output": "sarif-php-converters.phar",
   "force-autodiscovery": true,
   "dump-autoload": false,
   "exclude-dev-files": false,
   "files": [
       "autoload.php",
       "report-converter.php"
   ],
   "finder": [
       {
           "name": "*.php",
           "exclude": [
               "examples",
               "resources",
               "test",
               "tests"
           ],
           "in": [
               "vendor-bin/phan",
               "vendor-bin/phpcs",
               "vendor-bin/phpcs-fixer",
               "vendor-bin/phplint",
               "vendor-bin/phpmd",
               "vendor-bin/phpstan",
               "vendor-bin/psalm",
               "vendor-bin/twigcs-fixer"
           ]
       }
   ],
   "blacklist": [
       "vendor/bamarni/composer-bin-plugin/"
   ],
   "compression": "GZ"
}
Output
box compile -c box.json

output

Box version 4.6.2@29c3585 2024-04-23 19:35:41 UTC

 // Loading the configuration file "box.json".

🔨  Building the PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"

? Removing the existing PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"
? Skipping the Composer compatibility check: the autoloader is not dumped
? No compactor to register
? Adding main file: /shared/backups/bartlett/sarif-php-converters/report-converter
? Adding requirements checker
? Adding binary files
    > No file found
? Auto-discover files? Yes
? Exclude dev files? No
? Adding files
    > 7172 file(s)
? Generating new stub
  - Using shebang line: #!/usr/bin/env php
  - Using banner:
    > Generated by Humbug Box 4.6.2@29c3585.
    >
    > @link https://github.com/humbug/box
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? Compressing with the algorithm "GZ"
    > Warning: the extension "zlib" will now be required to execute the PHAR
? Setting file permissions to 0755
* Done.

💡  1 recommendation found:
    - The "exclude-dev-files" setting can be omitted since is set to its default value
No warning found.

 // PHAR: 7205 files (9.71MB)
 // You can inspect the generated PHAR with the "info" command.

 // Memory usage: 121.51MB (peak: 123.61MB), time: 8secs

Once compiled, try to run the PHAR, but got :

Fatal error: Uncaught RuntimeException: Unable to find "vendor/autoload.php" in "phar:///shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"

After investigation, checks with box info sarif-php-converters.phar -l -m flat command, I found that vendor/autoload.php is not included.

The reason force-autodiscovery (enabled) and dump-autoload (disabled) are incompatible.

If I removed the dump-autoload setting, and re-compile the PHAR, the vendor/autoload.php is included again and my application is able to run.

But, as I said #580 (comment), I cannot use the -d|--working-dir option of BOX compile (it was my workaround, but it has a limit !)

llaville added a commit to llaville/sarif-php-converters that referenced this issue Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant