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

Requirement checker wrongly detects the version #489

Closed
greg0ire opened this issue Oct 28, 2020 · 9 comments
Closed

Requirement checker wrongly detects the version #489

greg0ire opened this issue Oct 28, 2020 · 9 comments
Labels
Milestone

Comments

@greg0ire
Copy link

greg0ire commented Oct 28, 2020

Bug report

Question Answer
Box version 3.7.3
PHP version 7.4.11
Platform with version Fedora 33
Github Repo doctrine/migrations#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
@smoench
Copy link
Contributor

smoench commented Oct 29, 2020

@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.

@theofidry
Copy link
Member

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

@greg0ire
Copy link
Author

greg0ire commented Oct 29, 2020

I just pushed a commit that restricts to 7.1 using config.platform: doctrine/migrations@b3a5c51 (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 git@github.com: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

@theofidry
Copy link
Member

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)

@greg0ire
Copy link
Author

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

@theofidry
Copy link
Member

Will check it out ASAP

@dbrekelmans
Copy link

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

@theofidry
Copy link
Member

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

@greg0ire
Copy link
Author

Can't test right now but thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants