vercel/turborepo · error · CannotWriteLogs

error creating log file: {err:?}

Error message

error creating log file: {err:?}

What it means

After the log directory exists, LogWriter::with_log_file (crates/turborepo-ui/src/logs.rs:40) creates the log file itself via AbsoluteSystemPath::create(). If file creation fails, turbo emits this warning and returns Error::CannotWriteLogs(err), so no log file is attached to the task run.

Source

Thrown at crates/turborepo-ui/src/logs.rs:41

            log_file: None,
            writer: None,
        }
    }
}

impl<W: Write> LogWriter<W> {
    pub fn with_log_file(&mut self, log_file_path: &AbsoluteSystemPath) -> Result<(), Error> {
        log_file_path.ensure_dir().map_err(|err| {
            turborepo_log::warn(
                turborepo_log::Source::turbo(turborepo_log::Subsystem::Logs),
                format!("error creating log file directory: {err:?}"),
            )
            .emit();
            Error::CannotWriteLogs(err)
        })?;

        let log_file = log_file_path.create().map_err(|err| {
            turborepo_log::warn(
                turborepo_log::Source::turbo(turborepo_log::Subsystem::Logs),
                format!("error creating log file: {err:?}"),
            )
            .emit();
            Error::CannotWriteLogs(err)
        })?;

        self.log_file = Some(BufWriter::new(log_file));

        Ok(())
    }

    pub fn with_writer(&mut self, writer: W) {
        self.writer = Some(writer);
    }
}

impl<W: Write> Write for LogWriter<W> {

View on GitHub (pinned to f9245100cf)

Solutions

  1. Check for a directory occupying the log file path and remove stale .turbo/cache artifacts (rm -rf .turbo or the configured cache dir).
  2. Verify free disk space (df -h) and clear space if full.
  3. Confirm file-level write permission on the containing directory for the invoking user; move TURBO_CACHE_DIR to a writable path if not.
  4. Disable or pause antivirus/lockdown software that blocks file creation in cache paths on Windows.

Example fix

# before: stale directory blocks the log file path
rm -rf .turbo && ls -la .turbo  # shows a dir where the log file should live

# after: clean stale state so the log file can be created
rm -rf .turbo
turbo run build
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
CACHE_DIR="${TURBO_CACHE_DIR:-.turbo/cache}"
df -h "$CACHE_DIR" | awk 'NR==2 && $5+0 > 90 { print "disk nearly full — cache writes may fail" > "/dev/stderr"; exit 1 }'
[ -d "$CACHE_DIR" ] && [ ! -w "$CACHE_DIR" ] && { echo "cache dir read-only" >&2; exit 1; }
turbo run build

Prevention

When it happens

Trigger: ensure_dir() succeeds but create() fails: the target path already exists as a directory, permission is denied at the file level, the filesystem is read-only, or the disk is full (ENOSPC) at write time.

Common situations: Disk-full CI runners, a stale directory left at the exact log file path (e.g. after a crashed run), read-only mounts, or restrictive file ACLs/antivirus on Windows preventing file creation inside the cache directory.

Related errors


AI-assisted analysis of vercel/turborepo@f9245100cf (2026-08-17). Data as JSON: /api/errors/7c4d6a276a553a06. Report an issue: GitHub.