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

Bug: Unable to create file /github/home/.composer/config.json in Github Action

chris-bateman opened this issue · comments

New Issue

Unable to create file /github/home/.composer/config.json

Diagnose

If you use a Composer installation, please specify:

Output of `composer show` command
...REPLACE ME...

If you use Docker image of PHP Lint, please specify:

Output of `docker inspect overtrue/phplint:latest` command
...REPLACE ME...

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

Output of `phplint.phar --manifest` command
...REPLACE ME...

Summary

Version 9.0.3 works correctly.
Moving to version 9.0.4 or greater results in the below error.

In ConfigCommand.php line 207:
touch(): Unable to create file /github/home/.composer/config.json because No such file or directory                                                     
                                                                               
config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--source] [--] [<setting-key> [<setting-value>...]]

/entrypoint.sh: line 13: ::error ::touch(): Unable to create file /github/home/.composer/config.json because No such file or directory/vendor/bin/phplint: not found

Github workflow file in use -

phplint:
        name: PHP Lint
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: overtrue/phplint@9.0.3

Expected behaviour

It runs successfully

Actual behaviour

image

Found origin of issue.
As I've no more free time today, I'll give explains and fixes later (probably tomorrow)

It's time to explains and understand why there are issues since v9.0.4, while v9.0.3 works as expected :

Look and compare Dockerfile both versions :

I've introduced a non-root user to avoid issue #182

I've also, introduced a new issue with line https://github.com/overtrue/phplint/blob/9.0.4/Dockerfile#L19.

Look and also compare entrypoint.sh both versions :

Until v9.0.3, PHPLint used Docker root (account), and hardcoded the path with /root/.composer/vendor/bin/phplint

I've tried to removed the hardcoded syntax by using this $(composer config --global home)/vendor/bin/phplint new syntax.

It will be ok, if GitHub Action Runner did not hardcode itself the HOME user directory (with /github/home value).
TL;DR: read actions/runner#863 for more information.

As it's not yet possible, unless GitHub Action team decide to revert their behaviour,
we should come back to a hardcoded path version of PHPLint into entrypoint.sh (but now with the non-root user).

Hope these explains are enough to understand current status of PHPLint !

Bugfix releases 9.0.7 and 9.1.1 are on way !

/cc @overtrue

Fix already available with version 9.0.8

I'll release then 9.1.1 accordingly

@chris-bateman I recommend to use the latest version 9.1.1 (quite similar to 9.0.8) unless you're still running with PHP 8.0 on your platform

@llaville Thank you for the quick turn around. Working perfectly now :)
image