phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 430 forks source link

Phpcs and PhpLint tasks fail on Windows 7 #275

Closed Bilge closed 4 years ago

Bilge commented 7 years ago
Q A
Branch master
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets n/a

Phpcs and PhpLint tasks are skipped on Windows 7 due to "the windows cmd input limit". As I understand, this error message is generated by GrumPHP so it is this project's prerogative to devise a suitable workaround for running these tasks on Windows.

My configuration Default.

Steps to reproduce:

  1. bin/grumphp run

Result:

GrumPHP is sniffing your code!
Running task 1/7: PhpParser
Running task 2/7: Phpcs
Oh no, we hit the windows cmd input limit!
Skipping task ...

Running task 3/7: Phpspec
Running task 4/7: Phpunit
Running task 5/7: Composer
Running task 6/7: PhpLint
Oh no, we hit the windows cmd input limit!
Skipping task ...

Running task 7/7: YamlLint
             âââââââââââââââââââââââââ
           âââââââââââââââââââââââââââââ
         ââââââââââââââââââââââââââââââââ
        ââââââââââââââââââââââââââââââââââ
        ââââââââââââââââââââââââââââââââââ
  ââââââââââââââââââââââââââââââââââââââââ
 âââââââââââââââââââââââââââââââââââââââââ
 âââââââââââââââââââââââââââââââââââââââââ
   âââââââââââââââââââââââââââââââââââââââ
     ââââââââââââââââââââââââââââââââââââââââââ
      ââââââââââââââ                 ââââââââââ
     ââââââââ                         âââââââ
      âââââ      âââ          ââ       âââââ
        âââ                            âââ
         ââ           ââ ââ           ââââ
        âââ       ââââââââââââ       ââââ
         âââ ââââââââââââââââââââââââââââ
        âââââââââââââââââââââââââââââââââ
          ââââââââââââââââââââââââââââââ
         ââââââââââââââââââââââââââââââ
          âââââââââââââââââââââââââââââ
           ââ âââââââââââââââââââââââââ
            â âââââââââââââââââââââ ââ
                ââââââââââââââââââ
                 âââ  ââââââ  âââ
                        âââ   ââ
       _    _ _                         _ _
      / \  | | |   __ _  ___   ___   __| | |
     / _ \ | | |  / _` |/ _ \ / _ \ / _` | |
    / ___ \| | | | (_| | (_) | (_) | (_| |_|
   /_/   \_\_|_|  \__, |\___/ \___/ \__,_(_)
                  |___/
The Windows maximum amount of 8191 input characters exceeded while running process: "vendor\bin\phpcs.BAT" "- ...
The Windows maximum amount of 8191 input characters exceeded while running process: "vendor\bin\parallel-lint ...
veewee commented 7 years ago

Currently, that is intended behaviour. You can find additional information here: https://github.com/phpro/grumphp/blob/master/src/GrumPHP/Util/Platform.php#L19 https://support.microsoft.com/en-us/kb/830473

The problem is that the CLI input string on cmd.exe is limited to 8191 characters. Tasks like phplint and phpcs contain the paths to the files that are being checked. During a run command, the list of files wil exceed this amount which results in some strange errors on windows.

That is why I've choosen to display the error message and mark the test as skipped.

I would accept a PR which contains a better solution.

Bilge commented 7 years ago

Why don't you just break it down into multiple invocations?

On 16 Jan 2017 07:50, "Toon Verwerft" notifications@github.com wrote:

Currently, that is intended behaviour. You can find additional information here: https://github.com/phpro/grumphp/blob/master/src/ GrumPHP/Util/Platform.php#L19 https://support.microsoft.com/en-us/kb/830473

The problem is that the CLI input string on cmd.exe is limited to 8191 characters. Tasks like phplint and phpcs contain the paths to the files that are being checked. During a run command, the list of files wil exceed this amount which results in some strange errors on windows.

That is why I've choosen to display the error message and mark the test as skipped.

I would accept a PR which contains a better solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/phpro/grumphp/issues/275#issuecomment-272793881, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcuYjNlR0Zn3IlfjKjAGkviIufMzozwks5rSyEngaJpZM4Lj4T_ .

veewee commented 7 years ago

That's a possible solution but it would require code changes in multiple tasks: Most of the tasks run only one process. Maybe the processes part could be abstracted into a new layer so that it doesn't matter if one or multiple tasks are started. The problem is only on Windows, so for other OS a split-up is not really necessary.

Bilge commented 7 years ago

The problem is only on Windows, so for other OS a split-up is not really necessary.

I'm not sure that's true. That's what the xargs command was created for, and as it shows us, the typical Linux limit is very generous.

$ xargs --show-limits POSIX upper limit on argument length (this system): 2607529 POSIX smallest allowable upper limit on argument length (all systems): 4096 Maximum length of command we could actually use: 2595666 Size of command buffer we are actually using: 131072

It is quite possible you just haven't hit the 2MB command line limit in any of your projects or tests but this remains a dormant problem waiting to happen.

veewee commented 7 years ago

I don't think I am going to hit the unix limit anytime soon, but I do agree that it is an issue. If you are committing 2MB of filenames at once, it might be easier to just run the executables on all the files. The same goes for Windows: if the limit is hit, it might be easier to just run the executables without the file list. What do you think?

Bilge commented 7 years ago

it might be easier to just run the executables on all the files

Absolutely not, for the following reasons.

  1. A user should only have to fix issues in files they modified, not in files they did not.
  2. In a very large project, such a scan could take a disproportionate amount of time to complete.
burzum commented 5 years ago

I'm also running into this issue. There is no fix for this yet?

Update: When running tortoise git grumphp works. But it doesn't and brings the limit error when I run it manually using the Windows Powershell.

Bilge commented 5 years ago

There is no fix for this yet?

Why do you ask that like it could have just magically fixed itself? If you're not going to put the work in, nothing's going to happen.

veewee commented 4 years ago

Fixed in #796

iva3682 commented 3 years ago

Hey! Same problem with phpmd and phpstan tasks!