Seldaek/monolog · error · UnexpectedValueException

There is no existing directory at "%s" and it could not be c

Error message

There is no existing directory at "%s" and it could not be created: {}

What it means

Error "There is no existing directory at "%s" and it could not be created: {}" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/StreamHandler.php:282

    private function createDir(string $url): void
    {
        // Do not try to create dir if it has already been tried.
        if (true === $this->dirCreated) {
            return;
        }

        $dir = $this->getDirFromStream($url);
        if (null !== $dir && !is_dir($dir)) {
            $this->errorMessage = null;
            // forwarding to $this->customErrorHandler using a closure to make the
            // private method accessible, see https://github.com/Seldaek/monolog/issues/1866
            set_error_handler(function (int $code, string $msg) {
                return $this->customErrorHandler($code, $msg);
            });
            $status = mkdir($dir, 0777, true);
            restore_error_handler();
            if (false === $status && !is_dir($dir) && strpos((string) $this->errorMessage, 'File exists') === false) {
                throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir));
            }
        }
        $this->dirCreated = true;
    }

    private function getInodeFromUrl(): ?int
    {
        if ($this->url === null || str_starts_with($this->url, 'php://')) {
            return null;
        }

        $inode = @fileinode($this->url);

        return $inode === false ? null : $inode;
    }

    private function hasUrlInodeWasChanged(): bool
    {

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/StreamHandler.php:282 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/01d0b8f0b4e53297. Report an issue: GitHub.