rector
rector copied to clipboard
Child process Error when running rector
Bug Report
Hello, I want to use rector to reformat my Doctrine Annotations. But when I start rector with --dry-run. it shows me the files and the rules. But it stops befor finishing with the Error:
[ERROR] Could not process some files, due to:
"Child process error: ".
The strange thing, is that the reason for the error is just empty. I use the latest 0.13.9 version.
I tried to use this instruction: https://getrector.org/blog/how-to-upgrade-annotations-to-attributes
So my rector.php file looks like this:
<?php
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\SensiolabsSetList;
use Rector\Nette\Set\NetteSetList;
use Rector\Config\RectorConfig;
return function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
NetteSetList::ANNOTATIONS_TO_ATTRIBUTES,
SensiolabsSetList::FRAMEWORK_EXTRA_61,
]);
};
Hi, thanks for reporting.
We'll need a minimal file and single rules this crashes on, so we can identify the weak spot.
Try to narrow the rector.php
to single set and run Rector on single file. Then we'll need the breaking line in the code.
The --debug
option might also help.
That's seems parallel process, could you try with disable parallel:
$rectorConfig->disableParallel();
and see if it is working?
If you're running on windows, I don't have windows11 at my local dev, so can't test the exact environment.
We need the exact step by step to reproduce the issue, (the file, the config, the command that run), better to use Github repository with github action running.
You may can create reproducible repository with Github action with windows for it https://github.blog/changelog/2022-01-11-github-actions-jobs-running-on-windows-latest-are-now-running-on-windows-server-2022/
It happens with every ruleset. I tried it with every rule extra. A sample file is attached to the comment. (I was not allowed to upload a .php file) Server.zip @samsonasik with your idea it worked. And the rules where applied.
This is the project where I try to run rector against the entity: https://github.com/H2-invent/jitsi-admin/tree/feature/sip_send_via_email I just added the rector file with the ruleset and created a new brnach for testing
I use windows 10, so this can be the problem as well.
I don't have windows10 at my local dev, so can't test the exact environment.
We need the exact step by step to reproduce the issue, (the file, the config, the command that run), better to use Github repository with github action running.
You may can create reproducible repository with Github action with windows for it https://github.blog/changelog/2022-01-11-github-actions-jobs-running-on-windows-latest-are-now-running-on-windows-server-2022/
Hello @samsonasik,
I created a github action with the project and rector doctrine annotation to attribute. https://github.com/holema/rector_parallel_test
I hope this can help :)
If it is of any help, I get similar error, but with some extra info:
PHP Fatal error: Uncaught Error: Call to undefined function proc_terminate() in /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/child-process/src/Process.php:285
I get the same error on;
- Windows 10
- Windows Server 2019
- CloudLinux OS 8
I've tried a variety of entities, with various methods of annotations but this doesn't seem to have any effect on the error.
The full Stack Trace:
#0 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(116): RectorPrefix202207\React\ChildProcess\Process->terminate() #1 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(46): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ParallelProcess->quit() #2 /home/xxx/domains/xxx/vendor/rector/rector/packages/Parallel/Application/ParallelFileProcessor.php(138): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ProcessPool->quitProcess() #3 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(126): Rector\Parallel\Application\ParallelFileProcessor->Rector\Parallel\Application\{closure}() #4 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ParallelProcess->RectorPrefix202207\Symplify\EasyParallel\ValueObject\{closure}() #5 /home/xxx/domains/xxx/vendor/rector/rector/vendor/clue/ndjson-react/src/Decoder.php(110): RectorPrefix202207\Evenement\EventEmitter->emit() #6 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\Clue\React\NDJson\Decoder->handleData() #7 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/stream/src/Util.php(62): RectorPrefix202207\Evenement\EventEmitter->emit() #8 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\React\Stream\Util::RectorPrefix202207\React\Stream\{closure}() #9 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/stream/src/DuplexResourceStream.php(154): RectorPrefix202207\Evenement\EventEmitter->emit() #10 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(201): RectorPrefix202207\React\Stream\DuplexResourceStream->handleData() #11 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(173): RectorPrefix202207\React\EventLoop\StreamSelectLoop->waitForStreamActivity() #12 /home/xxx/domains/xxx/vendor/rector/rector/packages/Parallel/Application/ParallelFileProcessor.php(160): RectorPrefix202207\React\EventLoop\StreamSelectLoop->run() #13 /home/xxx/domains/xxx/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(251): Rector\Parallel\Application\ParallelFileProcessor->process() #14 /home/xxx/domains/xxx/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(135): Rector\Core\Application\ApplicationFileProcessor->runParallel() #15 /home/xxx/domains/xxx/vendor/rector/rector/src/Console/Command/ProcessCommand.php(119): Rector\Core\Application\ApplicationFileProcessor->run() #16 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Command/Command.php(307): Rector\Core\Console\Command\ProcessCommand->execute() #17 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(891): RectorPrefix202207\Symfony\Component\Console\Command\Command->run() #18 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(310): RectorPrefix202207\Symfony\Component\Console\Application->doRunCommand() #19 /home/xxx/domains/xxx/vendor/rector/rector/src/Console/ConsoleApplication.php(49): RectorPrefix202207\Symfony\Component\Console\Application->doRun() #20 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(208): Rector\Core\Console\ConsoleApplication->doRun() #21 /home/xxx/domains/xxx/vendor/rector/rector/bin/rector.php(128): RectorPrefix202207\Symfony\Component\Console\Application->run() #22 /home/xxx/domains/xxx/vendor/rector/rector/bin/rector(5): require_once('/home/xxx...') #23 /home/xxx/domains/xxx/vendor/bin/rector(117): include('/home/xxx...') #24 {main} thrown in /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/child-process/src/Process.php on line 285 Fatal error: Uncaught Error: Call to undefined function proc_terminate() in /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/child-process/src/Process.php:285 Stack trace: #0 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(116): RectorPrefix202207\React\ChildProcess\Process->terminate() #1 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(46): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ParallelProcess->quit() #2 /home/xxx/domains/xxx/vendor/rector/rector/packages/Parallel/Application/ParallelFileProcessor.php(138): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ProcessPool->quitProcess() #3 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(126): Rector\Parallel\Application\ParallelFileProcessor->Rector\Parallel\Application\{closure}() #4 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\Symplify\EasyParallel\ValueObject\ParallelProcess->RectorPrefix202207\Symplify\EasyParallel\ValueObject\{closure}() #5 /home/xxx/domains/xxx/vendor/rector/rector/vendor/clue/ndjson-react/src/Decoder.php(110): RectorPrefix202207\Evenement\EventEmitter->emit() #6 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\Clue\React\NDJson\Decoder->handleData() #7 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/stream/src/Util.php(62): RectorPrefix202207\Evenement\EventEmitter->emit() #8 /home/xxx/domains/xxx/vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): RectorPrefix202207\React\Stream\Util::RectorPrefix202207\React\Stream\{closure}() #9 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/stream/src/DuplexResourceStream.php(154): RectorPrefix202207\Evenement\EventEmitter->emit() #10 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(201): RectorPrefix202207\React\Stream\DuplexResourceStream->handleData() #11 /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(173): RectorPrefix202207\React\EventLoop\StreamSelectLoop->waitForStreamActivity() #12 /home/xxx/domains/xxx/vendor/rector/rector/packages/Parallel/Application/ParallelFileProcessor.php(160): RectorPrefix202207\React\EventLoop\StreamSelectLoop->run() #13 /home/xxx/domains/xxx/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(251): Rector\Parallel\Application\ParallelFileProcessor->process() #14 /home/xxx/domains/xxx/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(135): Rector\Core\Application\ApplicationFileProcessor->runParallel() #15 /home/xxx/domains/xxx/vendor/rector/rector/src/Console/Command/ProcessCommand.php(119): Rector\Core\Application\ApplicationFileProcessor->run() #16 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Command/Command.php(307): Rector\Core\Console\Command\ProcessCommand->execute() #17 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(891): RectorPrefix202207\Symfony\Component\Console\Command\Command->run() #18 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(310): RectorPrefix202207\Symfony\Component\Console\Application->doRunCommand() #19 /home/xxx/domains/xxx/vendor/rector/rector/src/Console/ConsoleApplication.php(49): RectorPrefix202207\Symfony\Component\Console\Application->doRun() #20 /home/xxx/domains/xxx/vendor/rector/rector/vendor/symfony/console/Application.php(208): Rector\Core\Console\ConsoleApplication->doRun() #21 /home/xxx/domains/xxx/vendor/rector/rector/bin/rector.php(128): RectorPrefix202207\Symfony\Component\Console\Application->run() #22 /home/xxx/domains/xxx/vendor/rector/rector/bin/rector(5): require_once('/home/xxx...') #23 /home/xxx/domains/xxx/vendor/bin/rector(117): include('/home/xxx...') #24 {main} thrown in /home/xxx/domains/xxx/vendor/rector/rector/vendor/react/child-process/src/Process.php on line 285
just guessing, it possibly due to different line endings:
2022-07-28T15:46:00.1269970Z [file] src/dataType/LdapType.php
2022-07-28T15:46:00.1270313Z [rule] Rector\Php80\Rector\Class_\AnnotationToAttributeRector
2022-07-28T15:46:00.1270436Z
2022-07-28T15:46:00.6369396Z
2022-07-28T15:46:00.6413590Z 64 files with changes
2022-07-28T15:46:00.6414146Z =====================
2022-07-28T15:46:00.6414365Z
2022-07-28T15:46:00.6415424Z 1) src/Controller/LobbyBroadcastController.php:0
2022-07-28T15:46:00.6415763Z
2022-07-28T15:46:00.6419632Z ---------- begin diff ----------
2022-07-28T15:46:00.6420213Z @@ @@
2022-07-28T15:46:00.6420603Z #Warning: Strings contain different line endings!
2022-07-28T15:46:00.6420945Z <?php
@samsonasik, This could be a reason, but why is it then working without parallel processes?
Could you try increase timeout and reduce max number process like in https://github.com/rectorphp/rector/issues/7323#issuecomment-1198534440
@juuuuln I'm checking your error report. The proc_terminate()
should be avilable on PHP 5-8: https://www.php.net/manual/en/function.proc-terminate.php
Any idea why it's missing on your PHP?
I found similar issue with missing proc_close. It was related to opcache: https://github.com/OOPS-ORG-PHP/mod_execdir/issues/22 Does that affect your code?
@TomasVotruba, Following your comment I performed a few actions to get it working again;
- Reinstalled PHP,
- Removed vendor dir, then composer install
- Added;
$rectorConfig->paths([ __DIR__ . '/src' ]);
Instead of entering it manually
Somehow this sequence of actions fixed the problems on my end. Your suggestion was very valuable @TomasVotruba, thank you! :)
@holema disable parallel with extract to multiple commands seems working https://github.com/samsonasik/rector_parallel_test/runs/7592084313?check_suite_focus=true
vendor/bin/rector process src/Command
vendor/bin/rector process src/Controller
vendor/bin/rector process src/DataFixture
vendor/bin/rector process src/dataType
vendor/bin/rector process src/Entity
vendor/bin/rector process src/Form
vendor/bin/rector process src/Helper
vendor/bin/rector process src/Message
vendor/bin/rector process src/MessageHandler
vendor/bin/rector process src/Repository
vendor/bin/rector process src/Security
vendor/bin/rector process src/Service
vendor/bin/rector process src/Twig
vendor/bin/rector process src/Kernel.php src/UtilsHelper.php
with config:
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\SensiolabsSetList;
use Rector\Nette\Set\NetteSetList;
use Rector\Config\RectorConfig;
return function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
NetteSetList::ANNOTATIONS_TO_ATTRIBUTES,
SensiolabsSetList::FRAMEWORK_EXTRA_61,
]);
$rectorConfig->paths([__DIR__ . '/src']);
$rectorConfig->disableParallel();
};
see https://github.com/samsonasik/rector_parallel_test/pull/1, and that only took 39 seconds to process, so it seems the solution for now is to disable parallel.
I'm checking your error report. The
proc_terminate()
should be avilable on PHP 5-8: php.net/manual/en/function.proc-terminate.php Any idea why it's missing on your PHP?
maybe the problem happens when the proc_*
function listed on disabled_functions
?
https://www.php.net/manual/en/ini.core.php#ini.disable-functions
if so, it would need a function_exists
check beforehand
Possibly, some extension possibly need to be in suggest for running parallel:
https://github.com/rectorphp/rector/blob/1d28ca109ca536e8034c3c756ee61c65e6e63c8a/vendor/react/event-loop/composer.json#L39
@samsonasik I aded a branch with disablee parall processing and the action worked. https://github.com/holema/rector_parallel_test/runs/7647538308?check_suite_focus=true
The pcntl is not available for windows. https://github.com/holema/rector_parallel_test/runs/7647558568?check_suite_focus=true https://stackoverflow.com/questions/33036773/how-to-enable-pcntl-in-php-while-using-a-framework-like-symfony2
I'm looking at PHPStan setup, where we ported the parallel process from, and it seem they no longer use pcntl
: https://github.com/phpstan/phpstan-src/commit/a5d94015881824b275f08212e6063eaa879aa268
Maybe we could drop it here too.
@holema An idea to verify this, does PHPStan parallel run on your system?
If relevant, I can confirm latest phpstan parallel is working on my windows machine at least. Its not a general windows problem
@TomasVotruba, PHPSTan is worlking as @staabm said. https://github.com/holema/rector_parallel_test/runs/7648545836?check_suite_focus=true The Actoin only fails because there are so many errors.
@holema Thanks for the input.
I see the failing job: https://github.com/holema/rector_parallel_test/runs/7489361491
Yet the output is huge and I could not find the "proc_terminate
not found" issue. That's a different use case then.
Could you narrow it down to few files that cause this error? I assume there will be combination of few PHP lines and Rector rule that crashes on it.
I tried to debug and narrow down the failing test fixture. In the end it's ~5 lines file, see: https://github.com/TomasVotruba/rector_parallel_test_ownci
The issue is somehow in line-endings. Try to use different ones.
Ideally go for "\n", as that is the constant value in php-parser itself: https://github.com/nikic/PHP-Parser/blob/0201a7ee3f86c856eb009e1393fdd654b9667684/lib/PhpParser/PrettyPrinterAbstract.php#L165
The php-parser possibly related issue: https://github.com/nikic/PHP-Parser/issues/215
I noticed this issue when running our own phpstan job simultaneously. Maybe they share some temp files, or it is just out of memory, phpstan requires a lot sometimes. For phpstorm users: this can run silent in background during code inspection (when configured). btw. I use linux, so this may not be os related.
@holema it should be resolved at https://github.com/symplify/symplify/pull/4417 , wait for next symplify/easy-paralell
release to be used in rector scoped.
The Symplify release is on the way. ETA 10 mins
rector will require re-tag because it included in scoped vendor.