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

Build fails with "Call to undefined function get_debug_type()" #550

Closed
Anyqax opened this issue Apr 30, 2021 · 7 comments · Fixed by #579
Closed

Build fails with "Call to undefined function get_debug_type()" #550

Anyqax opened this issue Apr 30, 2021 · 7 comments · Fixed by #579
Labels

Comments

@Anyqax
Copy link

Anyqax commented Apr 30, 2021

Bug report

Question Answer
Box version 3.12.2@42e0a50
PHP version 7.4.16
Platform with version Ubuntu

When trying to build with the latest 3.12.2 .phar Release, I get the error:

./box compile --no-restart -vvv
PHP Fatal error:  Uncaught Error: Call to undefined function _HumbugBox48cf944fc33a\Symfony\Component\Console\get_debug_type() in phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php:523

I've tried earlier releases back to 3.8.5 but all with the same error.
This only happens on our jenkins server, locally (a windows machine) works fine.
Unfortunately I can't try the global composer installation on jenkins since we get dependency conflicts.

box.json
{
   "compression": "GZ",
   "main": "bin/console",
   "output": "dist/deployer.phar",
   "check-requirements": false,
   "exclude-composer-files": false,
   "dump-autoload": false,
   "finder": [
       {
           "in": ".",
           "exclude": [
               "dist",
               "vendor",
               "spec",
               "bin/phpspec*",
               "bin/phpunit*",
               "phpspec.yml",
               "phpunit.xml.dist"
           ]
       },
       {

           "in": "vendor",
           "notName": "/[A-Za-z0-9_-].xml.dist/",
           "exclude": [
               "Test",
               "Tests",
               "test",
               "tests",
               "doc"
           ]
       }
   ],
   "git-version": "git-version"
}
Output
`Box Requirements Checker
========================

> Using PHP 7.4.16
> PHP is using the following php.ini file:
 /etc/php/7.4/cli/php.ini

> Checking Box requirements:
 ✔ The application requires the version "^7.2" or greater.
 ✔ The application requires the extension "zlib".
 ✔ The application requires the extension "phar".
 ✔ The package "beberlei/assert" requires the extension "json".
 ✔ The package "beberlei/assert" requires the extension "simplexml".
 ✔ The package "nikic/php-parser" requires the extension "tokenizer".
 
                                                                               
[OK] Your system is ready to run the application.                              
                                                                               

[debug] Current memory limit: "-1"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] The Xdebug extension is not loaded

   ____            
  / __ )____  _  __
 / __  / __ \| |/_/
/ /_/ / /_/ />  <  
/_____/\____/_/|_|  
                   

Box version 3.8.5@e708d75 2020-07-28 07:29:31 UTC

// Loading the configuration file "/var/lib/jenkins/workspace/Deployer         
// Client/Phar Build/box.json".                                                

🔨  Building the PHAR "/var/lib/jenkins/workspace/Deployer Client/Phar Build/dist/deployer.phar"


PHP Fatal error:  Uncaught Error: Call to undefined function _HumbugBox48cf944fc33a\Symfony\Component\Console\get_debug_type() in phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php:523
Stack trace:
#0 phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php(516): _HumbugBox48cf944fc33a\Symfony\Component\Console\Application->doActuallyRenderThrowable(Object(UnexpectedValueException), Object(_HumbugBox48cf944fc33a\Symfony\Component\Console\Output\StreamOutput))
#1 phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php(491): _HumbugBox48cf944fc33a\Symfony\Component\Console\Application->doRenderThrowable(Object(UnexpectedValueException), Object(_HumbugBox48cf944fc33a\Symfony\Component\Console\Output\StreamOutput))
#2 phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php(84): _HumbugBox48cf944fc33a\Symfony\Component\Console\Application- in phar:///var/lib/jenkins/workspace/Deployer Client/Phar Build/box/vendor/symfony/console/Application.php on line 523`
@theofidry
Copy link
Member

It is quite curious as this appears to break on the scoped Box code but I would except the CI to fail

@Anyqax
Copy link
Author

Anyqax commented May 15, 2021

Figured it out: The phar.readonly setting was set to 'On' on the CI server.
Either omitting the "--no-restart" or using "php -d phar.readonly=0 box.phar" works.
Maybe the check for the phar.readonly setting could be added to the Box Requirements Checker?

@theofidry
Copy link
Member

Nice to find it! Whilst it may explain why it went under the radar I still think the error needs fixing.

Maybe the check for the phar.readonly setting could be added to the Box Requirements Checker?

It's a bit hard to do as Box restart is there to avoid this (it makes it easier for the user) and there is no way to know that for the requirement checker in advance

@llaville
Copy link
Contributor

llaville commented Aug 4, 2021

I confirm that this issue still exists with latest version 3.13 of Box (3.13.0@275b091) and for all projects.

Trying to bypass with following command: BOX_REQUIREMENT_CHECKER=0 php -d phar.readonly=0 /usr/local/bin/box compile -vvv and xdebug disabled, without success

i.e with phplint branch 7.4 of latest version 3.0.3

box.json

output
[debug] Current memory limit: "512MB"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] phar.readonly is disabled
[debug] The Xdebug extension is not loaded
	____
   / __ )____  _  __
  / __  / __ \| |/_/
 / /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 3.13.0@275b091 2021-05-15 19:13:46 UTC

 // Loading the configuration file "/usr/local/src/phplint/box.json".

🔨  Building the PHAR "/usr/local/src/phplint/bin/phplint.phar"

? No compactor to register
? Adding main file: /usr/local/src/phplint/bin/phplint
? Adding requirements checker
? Adding binary files
	> No file found
? Auto-discover files? Yes
? Exclude dev files? Yes
? Adding files
	> 233 file(s)
? Generating new stub
  - Using shebang line: #!/usr/bin/env php
  - Using banner:
	> This file is part of the overtrue/phplint
	>
	> (c) overtrue <i@overtrue.me>
	>
	> This source file is subject to the MIT license that is bundled
	> with this source code in the file LICENSE.
? Dumping the Composer autoloader


Fatal error: Uncaught Error: Call to undefined function get_debug_type() in phar:///usr/local/bin/box/vendor/symfony/console/Application.php:528
Stack trace:
#0 phar:///usr/local/bin/box/vendor/symfony/console/Application.php(521): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->doActuallyRenderThrowable(Object(ErrorException), Object(_HumbugBox113887eee2b6\Symfony\Component\Console\Output\StreamOutput))
#1 phar:///usr/local/bin/box/vendor/symfony/console/Application.php(496): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->doRenderThrowable(Object(ErrorException), Object(_HumbugBox113887eee2b6\Symfony\Component\Console\Output\StreamOutput))
#2 phar:///usr/local/bin/box/vendor/symfony/console/Application.php(86): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->renderThrowable(Object(ErrorException), Object(_HumbugBox113887eee2b6\Symfony\Component\Console\Output\StreamOutput))
#3 phar:///usr/local/bin/box/vendor/symfony/console/Application.php(106): _HumbugBox113887eee2b6\Symfony\C in phar:///usr/local/bin/box/vendor/symfony/console/Application.php on line 528

With PHP 7.4.22 on Ubuntu 18.04

@llaville
Copy link
Contributor

llaville commented Aug 4, 2021

I've also tried a workaround with PHP 8.0.9 on Ubuntu 18.04, with same command, but have another issue (see output)

output ```
[debug] Current memory limit: "-1"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] phar.readonly is disabled
[debug] The Xdebug extension is not loaded
	____
   / __ )____  _  __
  / __  / __ \| |/_/
 / /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 3.13.0@275b091 2021-05-15 19:13:46 UTC

PHP Fatal error:  Uncaught Error: Class "Symfony\Polyfill\Mbstring\Mbstring" not found in phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/polyfill-mbstring/bootstrap80.php:48
Stack trace:
#0 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Helper/Helper.php(20): mb_detect_encoding()
#1 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Helper/Helper.php(62): _HumbugBox113887eee2b6\Symfony\Component\Console\Helper\Helper::strlen()
#2 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Style/SymfonyStyle.php(275): _HumbugBox113887eee2b6\Symfony\Component\Console\Helper\Helper::strlenWithoutDecoration()
#3 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Style/SymfonyStyle.php(41): _HumbugBox113887eee2b6\Symfony\Component\Console\Style\SymfonyStyle->createBlock()
#4 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Style/SymfonyStyle.php(75): _HumbugBox113887eee2b6\Symfony\Component\Console\Style\SymfonyStyle->block()
#5 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/src/Console/ConfigurationLoader.php(20): _HumbugBox113887eee2b6\Symfony\Component\Console\Style\SymfonyStyle->comment()
#6 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/src/Console/Command/ConfigurableBaseCommand.php(21): _HumbugBox113887eee2b6\KevinGH\Box\Console\ConfigurationLoader::getConfig()
#7 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/src/Console/Command/Compile.php(113): _HumbugBox113887eee2b6\KevinGH\Box\Console\Command\ConfigurableBaseCommand->getConfig()
#8 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/src/Console/Command/BaseCommand.php(19): _HumbugBox113887eee2b6\KevinGH\Box\Console\Command\Compile->executeCommand()
#9 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Command/Command.php(127): _HumbugBox113887eee2b6\KevinGH\Box\Console\Command\BaseCommand->execute()
#10 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Application.php(637): _HumbugBox113887eee2b6\Symfony\Component\Console\Command\Command->run()
#11 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Application.php(190): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->doRunCommand()
#12 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/console/Application.php(101): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->doRun()
#13 phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/bin/box(41): _HumbugBox113887eee2b6\Symfony\Component\Console\Application->run()
#14 /home/llaville/devilbox_data/backups/php/box-3.13.phar(18): require('...')
#15 {main}
  thrown in phar:///home/llaville/devilbox_data/backups/php/box-3.13.phar/vendor/symfony/polyfill-mbstring/bootstrap80.php on line 48

```

Same project https://github.com/overtrue/phplint with current branch 8.0 specialized for PHP 8

@theofidry theofidry added the bug label Aug 4, 2021
@llaville
Copy link
Contributor

@theofidry FYI, I cannot reproduced anymore the box compile issue (on PHP 7.4.22 and 8.0.9)
Probably because a vendor has changed but I'm not sure !

@theofidry
Copy link
Member

It should be possible to fix it by whitelisting the polyfills the idiomatic way as shown by humbug/php-scoper#440 (comment)

DAcodedBEAT pushed a commit to DAcodedBEAT/box that referenced this issue Dec 9, 2021
This commit resolves this issue around PHAR compilation:
```
PHP Fatal error:  Uncaught Error: Call to undefined function _HumbugBox48cf944fc33a\Symfony\Component\Console\get_debug_type()
```

The solution used is using a similar approach to humbug/php-scoper#481

Resolves box-project#550
theofidry added a commit that referenced this issue Feb 1, 2022
This commit resolves this issue around PHAR compilation:
```
PHP Fatal error:  Uncaught Error: Call to undefined function _HumbugBox48cf944fc33a\Symfony\Component\Console\get_debug_type()
```

The solution used is using a similar approach to humbug/php-scoper#481

Resolves #550

Co-authored-by: Arun Philip <aphilip@datto.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants