[Parallel] Handle Spaced root project main script on parallel process#4813
[Parallel] Handle Spaced root project main script on parallel process#4813samsonasik merged 5 commits intomainfrom
Conversation
eda078f to
f56ba27
Compare
|
Step to reproduce error locally:
|
|
@paulbalandan it seems double quoted is needed for generated main script: |
Yes, single quotes won't work |
|
@paulbalandan On linux, single quote can go to target dir: so the issue is somewhere on extracting space ... |
|
For side note: this issue is also happen even on Linux and macOs |
|
The issue seems deep on https://github.com/reactphp/child-process, when I replace: on rector-src/packages/Parallel/Command/WorkerCommandLineFactory.php Lines 96 to 113 in 2384073 into: it processed as: -/Users/samsonasik/www/spaced\ prj\ sample/target/rector.php
+/Users/samsonasik/www/spaced\\ prj\\ sample/target/rector.php
|
|
maybe open a new issue in the component to discuss it? |
|
The issue seems on `--config '/path/to/rector.php' that the "root" project contains space usage, if that can be trimmed to only relative path, it probably should can be resolved, trying with manually: -$workerCommandArray[] = \escapeshellarg((string) $input->getOption(Option::CONFIG));
+$workerCommandArray[] = 'rector.php';solve the issue, so the condition should be:
|
|
@staabm @paulbalandan I tried manually using this change seems solve the issue: $config = (string) $input->getOption(Option::CONFIG);
$filePathHelper = new \Rector\Core\FileSystem\FilePathHelper(new \RectorPrefix202307\Symfony\Component\Filesystem\Filesystem());
$workerCommandArray[] = escapeshellarg($filePathHelper->relativePath(realpath($config)));I will push a commit. |
a32fb72 to
41fd69e
Compare
|
@paulbalandan @staabm @sh1hab it should be working ok now, I will merge it and let you test 5 minutes after it merged:
to test this, update with the following command: |
$ composer info -D
codeigniter/coding-standard v1.7.8 Official Coding Standards for CodeIgniter based on PHP CS Fixer
codeigniter/phpstan-codeigniter v1.1.3.70400 CodeIgniter extensions and rules for PHPStan
ergebnis/composer-normalize 2.36.0 Provides a composer plugin for normalizing composer.json.
fakerphp/faker v1.23.0 Faker is a PHP library that generates fake data for you.
kint-php/kint 5.0.7 Kint - debugging tool for PHP developers
laminas/laminas-escaper 2.12.0 Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs
mikey179/vfsstream v1.6.11 Virtual file system to mock the real file system in unit tests.
nexusphp/cs-config v3.15.0 A factory for custom rulesets for PHP CS Fixer.
nexusphp/tachycardia v1.4.0 Detects slow running tests in your PHPUnit-driven test suites.
php-coveralls/php-coveralls v2.6.0 PHP client library for Coveralls API
phpstan/extension-installer 1.3.1 Composer plugin for automatic installation of PHPStan extensions
phpstan/phpstan 1.10.34 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-strict-rules 1.5.1 Extra strict and opinionated rules for PHPStan
phpunit/phpcov 8.2.1 CLI frontend for php-code-coverage
phpunit/phpunit 9.6.12 The PHP Unit Testing framework.
predis/predis v2.2.2 A flexible and feature-complete Redis client for PHP.
psr/log 1.1.4 Common interface for logging libraries
rector/rector dev-main 5f78db9 Instant Upgrade and Automated Refactoring of any PHP code
vimeo/psalm 5.15.0 A static analysis tool for finding errors in PHP applications$ vendor/bin/rector process system
Could not open input file: C:\Users\P\Desktop\Web |
|
@paulbalandan hm.., that's strange, I can't reproduce on macOS: ➜ target git:(main) ✗ pwd
/Users/samsonasik/www/spaced prj sample/target
➜ target git:(main) ✗ vendor/bin/rector process --clear-cache --dry-run
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================
1) src/Foo.php:0
---------- begin diff ----------
@@ @@
<?php
-final class Foo
+final readonly class Foo
{
- private readonly int $bar = 1;
+ private int $bar = 1;
}
----------- end diff -----------
Applied rules:
* ReadOnlyClassRector (https://wiki.php.net/rfc/readonly_classes)
[OK] 1 file would have changed (dry-run) by Rector
|
|
@paulbalandan could you probably check if there is something missing on rector-src/packages/Parallel/Command/WorkerCommandLineFactory.php Lines 114 to 115 in d188b67 it probably some tweak on escapeshellarg vs escapeshellcmd on windows env. thank you. |
|
@paulbalandan is changing to -$workerCommandArray[] = \escapeshellarg($this->filePathHelper->relativePath($config));
+$workerCommandArray[] = \escapeshellcmd($this->filePathHelper->relativePath($config));or probably you can check what's wrong there on windows OS :) |
|
|
yes, you need to pass |
this still is just a workaround. I think report a problem to the upstream component is the way to solve the underlying problem, or at least get better feedback on how to fix it on our end |
|
@staabm sure, I created issue for that: |
1 similar comment
|
@staabm sure, I created issue for that: |
|
Okay, some weird changes.
/**
* @param class-string<Command> $mainCommandClass
*/
public function create(string $mainScript, string $mainCommandClass, string $workerCommandName, InputInterface $input, string $identifier, int $port) : string
{
+ $mainScript = $this->filePathHelper->relativePath($mainScript);
$commandArguments = \array_slice($_SERVER['argv'], 1);
$args = \array_merge([\PHP_BINARY, $mainScript], $commandArguments);
$ vendor/bin/rector process system --clear-cache
Could not open input file: C:\Users\P\Desktop\Web
$ vendor/bin/rector process system --xdebug --clear-cache
437/437 [============================] 100%
[OK] Rector is done!
|
|
@paulbalandan interesting, you may need to debug in here: rector-src/src/Console/ConsoleApplication.php Lines 45 to 50 in d188b67 |
|
@paulbalandan I am testing on macOS, seems working ok: I don't have windows env so I will check on linux next. |
|
@paulbalandan I am testing on linux, seems working ok: |
|
@samsonasik I have isolated the issue to be from the terminal used. Your fix seems to be correct. However, the terminal used will be the problem for Windows.
However, I am not sure why this is the case 🤷 |
|
@paulbalandan thank you 👍 , well, at least working on other terminal (cmd, bash on windows), I think we can add note as known drawbacks on README.md for running paralle under pwsh (Powershell 7): https://github.com/rectorphp/rector-src/blob/main/build/target-repository/README.md#known-drawbacks could you write a PR for it? Thank you :) |
|
@samsonasik see #5022 |
@paulbalandan @sh1hab this is test for rectorphp/rector#8005
I copied existing test so I probablly missing the expecation assertion as currently shows:
Fixes rectorphp/rector#8005