{"record":{"id":"3413e83dae8c1b88","repo":"symfony/process","slug":"the-provided-cwd-s-does-not-exist","errorCode":null,"errorMessage":"The provided cwd \"%s\" does not exist.","messagePattern":"The provided cwd \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":373,"sourceCode":"        }\n\n        $envPairs = [];\n        foreach ($env as $k => $v) {\n            if (!\\is_scalar($v ?? '') && !$v instanceof \\Stringable) {\n                continue;\n            }\n\n            if (false !== $v && !\\in_array($k = (string) $k, ['', 'argc', 'argv', 'ARGC', 'ARGV'], true) && !str_contains($k, '=') && !str_contains($k, \"\\0\")) {\n                $envPairs[] = $k.'='.$v;\n            }\n        }\n\n        if ('\\\\' === \\DIRECTORY_SEPARATOR) {\n            $this->validateWindowsEnvBlockSize($envPairs);\n        }\n\n        if (!is_dir($this->cwd)) {\n            throw new RuntimeException(\\sprintf('The provided cwd \"%s\" does not exist.', $this->cwd));\n        }\n\n        $lastError = null;\n        set_error_handler(static function ($type, $msg) use (&$lastError) {\n            $lastError = $msg;\n\n            return true;\n        });\n\n        $oldMask = [];\n\n        if ($this->ignoredSignals && \\function_exists('pcntl_sigprocmask')) {\n            // we block signals we want to ignore, as proc_open will use fork / posix_spawn which will copy the signal mask this allow to block\n            // signals in the child process\n            pcntl_sigprocmask(\\SIG_BLOCK, $this->ignoredSignals, $oldMask);\n        }\n\n        try {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L355-L391","documentation":"Before launching the process, start() validates that the configured working directory exists (is_dir). If the cwd passed to the constructor or setWorkingDirectory does not exist on disk, the process could not start correctly, so a RuntimeException naming the bad path is thrown.","triggerScenarios":"new Process($cmd, $cwd) or ->setWorkingDirectory($cwd) with a non-existent path, then calling start()/run(); the check fires just before proc_open on non-Windows-independent code paths after Windows env validation.","commonSituations":"Hardcoded paths that differ between environments; cwd built from an artifact that was not created yet; typos or trailing configuration mistakes; containers where the directory was never mounted.","solutions":["Verify the directory with is_dir($cwd) before constructing/starting the Process.","Create the directory beforehand (mkdir($cwd, 0777, true)) if it should exist.","Log/inspect the resolved cwd value — it may come from config with a wrong default.","Correct the configuration or deployment so the directory exists at runtime."],"exampleFix":"// before\n$process = new Process(['composer', 'install'], $projectDir);\n$process->run();\n\n// after\nif (!is_dir($projectDir)) {\n    mkdir($projectDir, 0777, true);\n}\n$process = new Process(['composer', 'install'], $projectDir);\n$process->run();","handlingStrategy":"validation","validationCode":"$cwd = $options['cwd'] ?? getcwd();\nif (!is_dir($cwd)) {\n    throw new \\InvalidArgumentException(sprintf('Working directory does not exist: %s', $cwd));\n}\n$process = new Process($cmd, $cwd);","typeGuard":null,"tryCatchPattern":"try {\n    $process->run();\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'does not exist')) {\n        mkdir($this->cwd ?? $process->getWorkingDirectory(), 0777, true);\n        $process->run();\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Validate any config-provided cwd with is_dir at boot time, not at process launch.","Create working directories during deployment/setup rather than assuming they exist.","Log the resolved cwd (env-specific config can silently point elsewhere).","Use realpath() to canonicalize and detect bad paths early."],"tags":["php","symfony-process","cwd","filesystem"],"backgroundTag":"directory-not-found","analyzedSha":"99b85026db14a68f02c6f3eeb01a1170ca25c491","analyzedAt":"2026-09-14T11:23:33.683Z","contentChangedAt":"2026-09-14T11:23:33.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}