{"record":{"id":"65e0cd5c476ec125","repo":"vercel/turborepo","slug":"error-creating-log-file-directory-err","errorCode":null,"errorMessage":"error creating log file directory: {err:?}","messagePattern":"error creating log file directory: (.+?)","errorType":"console","errorClass":"CannotWriteLogs","httpStatus":null,"severity":"error","filePath":"crates/turborepo-ui/src/logs.rs","lineNumber":32,"sourceCode":"    log_file: Option<BufWriter<File>>,\n    writer: Option<W>,\n}\n\n/// Derive didn't work here.\n/// (we don't actually need `W` to implement `Default` here)\nimpl<W> Default for LogWriter<W> {\n    fn default() -> Self {\n        Self {\n            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","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-ui/src/logs.rs#L14-L50","documentation":"LogWriter::with_log_file (crates/turborepo-ui/src/logs.rs:31) must create the parent directory of the per-task log file before creating the file. When AbsoluteSystemPath::ensure_dir() fails, turbo emits this warning and returns Error::CannotWriteLogs(err). Task log capture (used for replaying cached output and `--output-logs`) therefore cannot start.","triggerScenarios":"Calling with_log_file with a path whose parent directory cannot be created: permission denied on an ancestor directory, a read-only filesystem, an ancestor path exists as a regular file, or the disk is full. The log path is normally under the cache directory, so an unwritable cache dir (custom TURBO_CACHE_DIR, sandboxed CI) triggers it.","commonSituations":"TURBO_CACHE_DIR pointed at a read-only or non-writable location (e.g. a mounted volume in Docker, a restricted shared runner directory), running as a user without write access to the repo/cache directory, a stale regular file occupying a path component that should be a directory, or disk-full conditions in CI.","solutions":["Check write permission and free space in the cache/log directory (often .turbo or $TURBO_CACHE_DIR): ls -ld <dir> and df -h.","Point the cache at a writable location: set TURBO_CACHE_DIR to a directory the build user can write.","Remove any regular file blocking the directory path (e.g. a file named like the directory under .turbo).","If running in a container or sandbox, mount or grant write access to the cache path, or disable log-file capture by not requesting persistent logs."],"exampleFix":"# before: cache dir on read-only mount\nexport TURBO_CACHE_DIR=/mnt/shared/turbo-cache   # -> error creating log file directory\n\n# after: writable cache dir\nexport TURBO_CACHE_DIR=/tmp/turbo-cache   # or a writable workspace path","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nCACHE_DIR=\"${TURBO_CACHE_DIR:-.turbo/cache}\"\nmkdir -p \"$CACHE_DIR\" 2>/dev/null || { echo \"cache dir unwritable: $CACHE_DIR\" >&2; exit 1; }\ntouch \"$CACHE_DIR/.write-test\" && rm \"$CACHE_DIR/.write-test\" \\\n  || { echo \"no write permission in $CACHE_DIR\" >&2; exit 1; }\nturbo run build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create the cache/log directory in CI setup scripts instead of relying on turbo to create it.","Point TURBO_CACHE_DIR at a volume the build user owns.","Monitor disk space; reserve headroom for cache and log writes."],"tags":["turborepo","logging","filesystem","permissions","cache-dir"],"backgroundTag":"directory-creation-permission-denied","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","schemaVersion":2},"datasetVersion":"2026-08-21T08:17:14.275Z"}