{"record":{"id":"2eb24b8db9f56f35","repo":"vercel/turborepo","slug":"error-opening-log-file-err","errorCode":null,"errorMessage":"error opening log file: {err:?}","messagePattern":"error opening log file: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/turborepo-ui/src/logs.rs","lineNumber":100,"sourceCode":"        if let Some(log_file) = &mut self.log_file {\n            log_file.flush()?;\n        }\n        if let Some(prefixed_writer) = &mut self.writer {\n            prefixed_writer.flush()?;\n        }\n\n        Ok(())\n    }\n}\n\npub fn replay_logs<W: Write>(\n    mut output: W,\n    log_file_name: &AbsoluteSystemPath,\n) -> Result<(), Error> {\n    debug!(\"start replaying logs\");\n\n    let log_file = File::open(log_file_name).map_err(|err| {\n        turborepo_log::warn(\n            turborepo_log::Source::turbo(turborepo_log::Subsystem::Logs),\n            format!(\"error opening log file: {err:?}\"),\n        )\n        .emit();\n        Error::CannotReadLogs(err)\n    })?;\n\n    let mut log_reader = BufReader::new(log_file);\n\n    let mut buffer = Vec::new();\n    loop {\n        let num_bytes = log_reader\n            .read_until(b'\\n', &mut buffer)\n            .map_err(Error::CannotReadLogs)?;\n        if num_bytes == 0 {\n            break;\n        }\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-ui/src/logs.rs#L82-L118","documentation":"replay_logs (crates/turborepo-ui/src/logs.rs:99) opens a previously written task log file to replay its output (typically after a cache hit or in watch mode). If File::open fails, turbo emits this warning and returns Error::CannotReadLogs(err); the stored log cannot be shown.","triggerScenarios":"Calling replay_logs with a path that does not exist (ENOENT — the log was deleted or never written), is not readable (EACCES), is a directory, or is locked by another process on Windows.","commonSituations":"A cache entry survives but its companion log file was pruned (turbo clean / cache eviction / manual deletion of files inside the cache dir), cache directory copied between machines with lost permissions, or concurrent runs racing over the same cache directory.","solutions":["If logs were pruned intentionally, clean the matching cache entry too so hits and logs stay consistent (remove the whole cache entry folder or run turbo clean).","Check the file exists and is readable: ls -l on the reported path; fix ownership/permissions of the cache dir.","Avoid sharing one cache directory between multiple concurrent machines/users; use per-user cache dirs or a remote cache.","If it recurs, capture the {err:?} detail — ENOENT points to pruning races, EACCES to permissions."],"exampleFix":"# before: cache hit references a pruned log file -> error opening log file: Os { code: 2 }\nturbo run build --force=false\n\n# after: evict the half-pruned entry so it is treated as a miss\nturbo clean   # or: rm -rf .turbo/cache/<hash-of-the-task>\nturbo run build","handlingStrategy":"fallback","validationCode":"#!/usr/bin/env bash\n# before replaying logs from a cache hit, confirm the log file exists\nLOG=\"$1\"\n[ -r \"$LOG\" ] || { echo \"log missing — treating as cache miss\" >&2; exit 3; }\ncat \"$LOG\"","typeGuard":null,"tryCatchPattern":"// replay_logs returns Result<(), turborepo_ui::Error>\nmatch replay_logs(&mut out, &log_path) {\n    Ok(()) => {}\n    Err(e) => {\n        // degrade gracefully: show a placeholder instead of failing the task view\n        eprintln!(\"(cached logs unavailable: {e:?})\");\n    }\n}","preventionTips":["Evict cache entries atomically — delete the whole entry folder including logs, never partial contents.","Give each user/runner its own cache directory to avoid cross-permission reads.","Back important runs with --output-logs=full or remote artifacts if logs must survive."],"tags":["turborepo","logging","cache","file-not-found","replay"],"backgroundTag":"log-file-missing","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}