@@ -79,27 +79,32 @@ public function create(string $mainScript, string $mainCommandClass, string $wor
7979 // disable colors, breaks json_decode() otherwise
8080 // @see https://github.com/symfony/symfony/issues/1238
8181 $ workerCommandArray [] = '--no-ansi ' ;
82+ // Only pass --config if explicitly set via command line
83+ // If not set, the worker will resolve config using RectorConfigsResolver fallback mechanism
8284 if ($ input ->hasOption (Option::CONFIG )) {
83- $ workerCommandArray [] = '--config ' ;
84- /**
85- * On parallel, the command is generated with `--config` addition
86- * Using escapeshellarg() to ensure the --config path escaped, even when it has a space.
87- *
88- * eg:
89- * --config /path/e2e/parallel with space/rector.php
90- *
91- * that can cause error:
92- *
93- * File /rector-src/e2e/parallel\" was not found
94- *
95- * the escaped result is:
96- *
97- * --config '/path/e2e/parallel with space/rector.php'
98- *
99- * tested in macOS and Ubuntu (github action)
100- */
101- $ config = (string ) $ input ->getOption (Option::CONFIG );
102- $ workerCommandArray [] = escapeshellarg ($ this ->filePathHelper ->relativePath ($ config ));
85+ $ configValue = $ input ->getOption (Option::CONFIG );
86+ if (is_string ($ configValue ) && $ configValue !== '' ) {
87+ $ workerCommandArray [] = '--config ' ;
88+ /**
89+ * On parallel, the command is generated with `--config` addition
90+ * Using escapeshellarg() to ensure the --config path escaped, even when it has a space.
91+ *
92+ * eg:
93+ * --config /path/e2e/parallel with space/rector.php
94+ *
95+ * that can cause error:
96+ *
97+ * File /rector-src/e2e/parallel\" was not found
98+ *
99+ * the escaped result is:
100+ *
101+ * --config '/path/e2e/parallel with space/rector.php'
102+ *
103+ * tested in macOS and Ubuntu (github action)
104+ */
105+ $ config = $ configValue ;
106+ $ workerCommandArray [] = escapeshellarg ($ this ->filePathHelper ->relativePath ($ config ));
107+ }
103108 }
104109 if ($ input ->getOption (Option::ONLY ) !== null ) {
105110 $ workerCommandArray [] = self ::OPTION_DASHES . Option::ONLY ;
@@ -112,8 +117,8 @@ private function shouldSkipOption(InputInterface $input, string $optionName): bo
112117 if (!$ input ->hasOption ($ optionName )) {
113118 return \true;
114119 }
115- // skip output format, not relevant in parallel worker command
116- return $ optionName === Option::OUTPUT_FORMAT ;
120+ // skip output format and config, handled separately in create()
121+ return $ optionName === Option::OUTPUT_FORMAT || $ optionName === Option:: CONFIG ;
117122 }
118123 /**
119124 * @return string[]
0 commit comments