box icon indicating copy to clipboard operation
box copied to clipboard

Requirement checker wrongly detects the version

Open greg0ire opened this issue 4 years ago • 7 comments

Bug report

Question Answer
Box version 3.7.3
PHP version 7.4.11
Platform with version Fedora 33
Github Repo https://github.com/doctrine/migrations/pull/1069

I'm trying to fix the doctrine/migrations build, and to migrate it from Travis to Github Actions at the same time. On both CI platforms, and also locally, the requirement checker tells me that the application requires ^7.2, which looks wrong to me since I can run composer install with PHP 7.1 before that. That works (meaning it tells me the application requires ^7.1) with older versions of box, but these versions give me the following error (which disappears with recent versions that still have the wrong detection):

PHP Parse error: syntax error, unexpected 'fn' (T_FN), expecting identifier (T_STRING) in phar:///home/greg/dev/doctrine-migrations/box.phar/vendor/nikic/iter/src/iter.fn.php on line 3

This leaves me no choice but to upgrade

box.json.dist
{
   "alias": "doctrine-migrations.phar",
   "compactors": [
       "Herrera\\Box\\Compactor\\Php",
       "Herrera\\Box\\Compactor\\Json"
   ],
   "compression": "GZ",
   "main": "bin/doctrine-migrations.php",
   "output": "build/doctrine-migrations.phar",
   "files-bin": [
       "LICENSE"
   ],
   "git-version": "git-version"
}

Output
Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
 /etc/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 "nikic/php-parser" requires the extension "tokenizer".
 ✔ The package "roave/better-reflection" requires the extension "json".
 
                                                                               
[OK] Your system is ready to run the application.                              
                                                                               

PHP Parse error:  syntax error, unexpected 'fn' (T_FN), expecting identifier (T_STRING) in phar:///home/greg/dev/doctrine-migrations/box.phar/vendor/nikic/iter/src/iter.fn.php on line 3

Parse error: syntax error, unexpected 'fn' (T_FN), expecting identifier (T_STRING) in phar:///home/greg/dev/doctrine-migrations/box.phar/vendor/nikic/iter/src/iter.fn.php on line 3

greg0ire avatar Oct 28 '20 22:10 greg0ire

@greg0ire I would recommend you to build the phar only for the minimum php target version as this phar file will be used for a release.

smoench avatar Oct 29 '20 08:10 smoench

It is fine to build the PHAR at a higher version, but only if you are manually setting the PHP platform to a fixed version which matches your lowest constraint. Otherwise you will run into the issue that you have things working with 7.4 because you are in 7.4, but this code does not execute in 7.1. When using it as a lib it does not matter since your dependencies are resolved with your current platform, but when shipping it as a PHAR it is like deploying an application: you need to be aware of the .lock and with what version the dependencies have been resolved

theofidry avatar Oct 29 '20 09:10 theofidry

I just pushed a commit that restricts to 7.1 using config.platform: https://github.com/doctrine/migrations/pull/1069/commits/b3a5c519c1f2257349b70ce3f2d9a72683bfadfb (and I run composer update after adding that setting)

I still get 7.2 as the detected version, is that expected?

Here is a reproducer:

git clone [email protected]:greg0ire/migrations.git
cd migrations
git switch --detach b3a5c519c1f2257349b70ce3f2d9a72683bfadfb
composer install
./download-box.sh && php box.phar compile -vvv
cat download-box.sh

If I edit the download-box.sh script to use 3.7.0, the version looks correct, but then it crashes:

Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
  /etc/php.ini

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

PHP Parse error:  syntax error, unexpected 'fn' (T_FN), expecting identifier (T_STRING) in phar:///tmp/migrations/box.phar/vendor/nikic/iter/src/iter.fn.php on line 3

Parse error: syntax error, unexpected 'fn' (T_FN), expecting identifier (T_STRING) in phar:///tmp/migrations/box.phar/vendor/nikic/iter/src/iter.fn.php on line 3

greg0ire avatar Oct 29 '20 12:10 greg0ire

That's definitely a bug; Could you try with 3.9.0? You will unfortunately need to either build the PHAR manually from the release or wait for the switch to GitHub Actions (which should be done shortly)

theofidry avatar Oct 29 '20 16:10 theofidry

Sadly I still have the issue with that version:

php box.phar --version
Box version 3.x-dev@412da71 2020-10-29 18:06:47 UTC
Full output
Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
  /etc/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: "512MB"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] phar.readonly is enabled
[debug] The Xdebug extension is not loaded
[debug] Configured `phar.readonly=0`
[debug] Async signals enabled (SIGINT = SIG_IGN)
[debug] Process restarting (BOX_ALLOW_XDEBUG=internal||1|*|*)
[debug] Running '/usr/bin/php' 'box.phar' 'compile' '-vvv' '--ansi'

Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
  /tmp/8stfwW

> 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: "512MB"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] Restarted (70 ms). The Xdebug extension is not loaded
[debug] Async signals enabled (SIGINT = SIG_DFL)

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

Box version 3.x-dev@412da71 2020-10-29 18:06:47 UTC

 // Loading the configuration file "/home/greg/dev/doctrine-migrations/box.json.dist".                                  

🔨  Building the PHAR "/home/greg/dev/doctrine-migrations/build/doctrine-migrations.phar"

? Removing the existing PHAR "/home/greg/dev/doctrine-migrations/build/doctrine-migrations.phar"
[debug] Increased the maximum number of open file descriptors from ("1024", "524288") to ("2176", "unlimited")
? Setting replacement values
  + @git-version@: 2.2.1-24-gb3a5c519
? Registering compactors
  + KevinGH\Box\Compactor\Php
  + KevinGH\Box\Compactor\Json
? Adding main file: /home/greg/dev/doctrine-migrations/bin/doctrine-migrations.php
? Adding requirements checker
? Adding binary files
    > 1 file(s)
? Auto-discover files? Yes
? Exclude dev files? Yes
? Adding files
    > 792 file(s)
? Generating new stub
  - Using shebang line: #!/usr/bin/env php
  - Using banner:
    > Generated by Humbug Box 3.x-dev@412da71.
    > 
    > @link https://github.com/humbug/box
? Dumping the Composer autoloader
    > '/home/greg/bin/composer' 'dump-autoload' '--classmap-authoritative' '--no-dev' '-vvv' '--ansi'
Generating optimized autoload files (authoritative)
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
Generated optimized autoload files (authoritative) containing 761 classes

Reading ./composer.json
Loading config file /home/greg/.composer/config.json
Loading config file /home/greg/.composer/auth.json
Loading config file ./composer.json
Checked CA file /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem: valid
Executing command (/tmp/box/Box89255): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/box/Box89255): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/tmp/box/Box89255): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/box/Box89255): hg branch
Executing command (/tmp/box/Box89255): fossil branch list
Executing command (/tmp/box/Box89255): fossil tag list
Executing command (/tmp/box/Box89255): svn info --xml
Reading /home/greg/.composer/composer.json
Loading config file /home/greg/.composer/config.json
Loading config file /home/greg/.composer/auth.json
Loading config file /home/greg/.composer/composer.json
Loading config file /home/greg/.composer/auth.json
Reading /home/greg/.composer/auth.json
Reading /tmp/box/Box89255/vendor/composer/installed.json
Reading /home/greg/.composer/vendor/composer/installed.json
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/object-enumerator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/global-state/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-timer/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-code-coverage/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/bootstrap/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/object-reflector/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/theseer/tokenizer/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/code-unit-reverse-lookup/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-token-stream/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/environment/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-file-iterator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/comparator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/di/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/schema/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/php-generator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/neon/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/exporter/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/diff/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/robot-loader/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/finder/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/recursion-context/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/utils/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/phpunit/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/resource-operations/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phar-io/manifest/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/version/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-text-template/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phar-io/version/src/" which does not appear to be a file nor a folder
Loading plugin PackageVersions\Installer
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/object-enumerator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/global-state/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-timer/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-code-coverage/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/bootstrap/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/object-reflector/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/theseer/tokenizer/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/code-unit-reverse-lookup/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-token-stream/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/environment/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-file-iterator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/comparator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/di/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/schema/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/php-generator/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/neon/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/exporter/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/diff/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/robot-loader/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/finder/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/recursion-context/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/nette/utils/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/phpunit/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/resource-operations/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phar-io/manifest/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/sebastian/version/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phpunit/php-text-template/src/" which does not appear to be a file nor a folder
Could not scan for classes inside "/tmp/box/Box89255/vendor/phar-io/version/src/" which does not appear to be a file nor a folder
Running 2.0.2 (2020-10-25 23:03:59) with PHP 7.4.11 on Linux / 5.8.16-300.fc33.x86_64
> post-autoload-dump: PackageVersions\Installer->dumpVersionsClass
Reading ./composer.lock

? Removing the Composer dump artefacts
? Compressing with the algorithm "GZ"
    > Warning: the extension "zlib" will now be required to execute the PHAR
[debug] Restored the maximum number of open file descriptors
? Setting file permissions to 0755
* Done.

💡  2 recommendations found:
    - The compactor "Herrera\Box\Compactor\Php" has been deprecated, use "KevinGH\Box\Compactor\Php" instead.
    - The compactor "Herrera\Box\Compactor\Json" has been deprecated, use "KevinGH\Box\Compactor\Json" instead.
No warning found.

 // PHAR: 835 files (673.45KB)                                                                                          
 // You can inspect the generated PHAR with the "info" command.                                                         

 // Memory usage: 23.55MB (peak: 25.26MB), time: 16secs                                                                 

[debug] Restarted process exited 0

greg0ire avatar Oct 29 '20 18:10 greg0ire

Will check it out ASAP

theofidry avatar Oct 29 '20 23:10 theofidry

I'm also running into this issue. Code is compatible with 7.1, but box is detecting a 7.2 requirement somehow.

https://github.com/dbrekelmans/release-action-test-source/runs/1545723577?check_suite_focus=true

dbrekelmans avatar Dec 13 '20 13:12 dbrekelmans

I've done a couple of checks and this should have been fixed now.

theofidry avatar Mar 14 '23 22:03 theofidry

Can't test right now but thanks!

greg0ire avatar Mar 15 '23 00:03 greg0ire