{"record":{"id":"7c4d6a276a553a06","repo":"vercel/turborepo","slug":"error-creating-log-file-err","errorCode":null,"errorMessage":"error creating log file: {err:?}","messagePattern":"error creating log file: (.+?)","errorType":"console","errorClass":"CannotWriteLogs","httpStatus":null,"severity":"error","filePath":"crates/turborepo-ui/src/logs.rs","lineNumber":41,"sourceCode":"            log_file: None,\n            writer: None,\n        }\n    }\n}\n\nimpl<W: Write> LogWriter<W> {\n    pub fn with_log_file(&mut self, log_file_path: &AbsoluteSystemPath) -> Result<(), Error> {\n        log_file_path.ensure_dir().map_err(|err| {\n            turborepo_log::warn(\n                turborepo_log::Source::turbo(turborepo_log::Subsystem::Logs),\n                format!(\"error creating log file directory: {err:?}\"),\n            )\n            .emit();\n            Error::CannotWriteLogs(err)\n        })?;\n\n        let log_file = log_file_path.create().map_err(|err| {\n            turborepo_log::warn(\n                turborepo_log::Source::turbo(turborepo_log::Subsystem::Logs),\n                format!(\"error creating log file: {err:?}\"),\n            )\n            .emit();\n            Error::CannotWriteLogs(err)\n        })?;\n\n        self.log_file = Some(BufWriter::new(log_file));\n\n        Ok(())\n    }\n\n    pub fn with_writer(&mut self, writer: W) {\n        self.writer = Some(writer);\n    }\n}\n\nimpl<W: Write> Write for LogWriter<W> {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-ui/src/logs.rs#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check for a directory occupying the log file path and remove stale .turbo/cache artifacts (rm -rf .turbo or the configured cache dir).","Verify free disk space (df -h) and clear space if full.","Confirm file-level write permission on the containing directory for the invoking user; move TURBO_CACHE_DIR to a writable path if not.","Disable or pause antivirus/lockdown software that blocks file creation in cache paths on Windows."],"exampleFix":"# before: stale directory blocks the log file path\nrm -rf .turbo && ls -la .turbo  # shows a dir where the log file should live\n\n# after: clean stale state so the log file can be created\nrm -rf .turbo\nturbo run build","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nCACHE_DIR=\"${TURBO_CACHE_DIR:-.turbo/cache}\"\ndf -h \"$CACHE_DIR\" | awk 'NR==2 && $5+0 > 90 { print \"disk nearly full — cache writes may fail\" > \"/dev/stderr\"; exit 1 }'\n[ -d \"$CACHE_DIR\" ] && [ ! -w \"$CACHE_DIR\" ] && { echo \"cache dir read-only\" >&2; exit 1; }\nturbo run build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clean stale .turbo state after crashed runs (rm -rf .turbo) so no directory occupies a log-file path.","Run builds with the same OS user that owns the cache directory.","Alert on disk usage above ~90% in CI before invoking turbo."],"tags":["turborepo","logging","filesystem","permissions","disk-full"],"backgroundTag":"file-creation-permission-denied","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","schemaVersion":2},"datasetVersion":"2026-08-21T10:36:37.832Z"}