overtrue / phplint

:bug: A tool that can speed up linting of php files by running several lint processes at once.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught Error: Failed opening required 'phar:///usr/local/bin/phplint/config/bootstrap.php'

nvuillam opened this issue · comments

New Issue

Diagnose

If you use PHAR version of PHP Lint, please specify:

Installed with phive: phive --no-progress install overtrue/phplint --force-accept-unsigned -g

Installation log from MegaLinter Dockerfile process:

#13 [stage-0  5/18] RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g
#13 0.075 Phive 0.15.2 - Copyright (C) 2015-2024 by Arne Blankerts, Sebastian Heuer and Contributors
#13 0.291 Downloading https://api.github.com/rate_limit
#13 0.894 Downloading https://api.github.com/repos/overtrue/phplint/releases?per_page=100
#13 1.523 Downloading https://github.com/overtrue/phplint/releases/download/9.1.1/phplint.phar
#13 1.538 Copying phplint-9.1.1.phar to /usr/local/bin/phplint
#13 1.540 
#13 DONE 1.6s

Summary

Fatal error while calling any phplint command

Expected behaviour

No fatal error

Actual behaviour

Example 1 with phplint -h

DEBUG    root:Linter.py:1129 Linter help command: ['phplint', '-h']
DEBUG    root:Linter.py:1144 Linter help result: 255 PHP Warning:  require_once(phar:///usr/local/bin/phplint/config/bootstrap.php): Failed to open stream: phar error: "config/bootstrap.php" is not a file in phar "/usr/local/bin/phplint" in phar:///usr/local/bin/phplint/bin/phplint on line 7
PHP Fatal error:  Uncaught Error: Failed opening required 'phar:///usr/local/bin/phplint/config/bootstrap.php' (include_path='.:/usr/share/php81') in phar:///usr/local/bin/phplint/bin/phplint:7

Example 2

[phplint] command: ['phplint', '-c', '/action/lib/.automation/.phplint.yml', 'php_good_1.php', 'php_good_2.php']
[phplint] CWD: /tmp/lint/.automation/test/php
[phplint] result: 255 PHP Warning:  require_once(phar:///usr/local/bin/phplint/config/bootstrap.php): Failed to open stream: phar error: "config/bootstrap.php" is not a file in phar "/usr/local/bin/phplint" in phar:///usr/local/bin/phplint/bin/phplint on line 7
PHP Fatal error:  Uncaught Error: Failed opening required 'phar:///usr/local/bin/phplint/config/bootstrap.php' (include_path='.:/usr/share/php81') in phar:///usr/local/bin/phplint/bin/phplint:7
Stack trace:
#0 /usr/local/bin/phplint(18): require()
#1 {main}
  thrown in phar:///usr/local/bin/phplint/bin/phplint on line 7

Full job logs is available here: https://github.com/oxsecurity/megalinter/actions/runs/7789108227/job/21240023175?pr=3341

This issue affect only PHAR version 9.1.1 and not 9.0.8 !
Will checks it.

While contents of BOX config file v9.1 is almost the same as v9.0 (except compression directive)

We use BOX v6 to build PHAR version of v9.1, while we use BOX v5 to build PHAR version of v9.0

Even if I try to follow the SOLID design principle, and especially the single responsability principle
by splitting the autoloader in its own file config/bootstrap.php, we've got another issue when trying to build the PHAR version 9.1.1 with BOX project v5 or v6.

Even if I found new issues with BOX v6 that was not present with BOX v5, it's not the fault of BOX project here.

When you don't specify files or directories directives into box.json config file, the Auto-discover feature is enabled.
But BOX is not able to detect a file included inside another like that => https://github.com/overtrue/phplint/blob/9.1.1/bin/phplint#L6

So the solution to fix this problem is to use force-autodiscovery directive.

PS: @nvuillam Thanks for reporting, a new version 9.1.2 will be soon available !

@llaville you're welcome. for once i'm useful to one of your repos, and not the contrary 😅

Meanwhile i downgraded phplint in MegaLinter and it's ok ^^

Version 9.1.2 is available

Thanks for your reactivity :)