facebook/flow · error
Failed to open log file '{}': {}
Error message
Failed to open log file '{}': {} What it means
When the Flow server daemonizes, open_log_file() opens its log with create+append. try_open_log_file() first rotates an existing log to <file>.old (best-effort) and then opens the target; any open error is turned into this message and open_log_file panics on it. The log lives under the server temp dir, so failures here are almost always temp-dir permission or existence problems.
Source
Thrown at rust_port/crates/flow_server/src/server_daemon.rs:246
}
fs::rename(file, &old_file)?;
Ok(())
})() {
eprintln!(
"Log rotate: failed to move '{}' to '{}'\n{}",
file, old_file, e
);
}
}
fs::OpenOptions::new()
.create(true)
.append(true)
.open(file)
.map_err(|e| format!("Failed to open log file '{}': {}", file, e))
}
pub fn open_log_file(file: &str) -> fs::File {
try_open_log_file(file).unwrap_or_else(|e| panic!("{}", e))
}
pub fn daemonize(
init_id: &str,
log_file: &str,
argv: &[String],
lazy_mode: Option<String>,
no_flowlib: bool,
ignore_version: bool,
options: Arc<Options>,
file_watcher_pid: Option<u32>,
start_cause: flow_server_env::server_status::StartCause,
cli_overrides: &CliOverrides,
) -> Result<Handle<(), ()>, String> {
let entry = registered_entry_point();
let root = &options.root;
let tmp_dir = &options.temp_dir;
let flowconfig_name = &options.flowconfig_name;View on GitHub (pinned to f88ac94bcf)
Solutions
- From the panic message, check the log directory: mkdir -p the parent and chown/chmod it to the daemon user.
- Remove stale root-owned log and .old files: rm <file> <file>.old under the temp dir.
- Set temp_dir (or TMPDIR) to a location the daemon user can write and restart.
- Check df -h and mount ro flags when permissions look correct.
Example fix
# before: temp dir missing / owned by another user flow daemon start ... # panic: Failed to open log file '/tmp/flow/x/log': ... # after mkdir -p /tmp/flow/x && chown "$(id -un)" /tmp/flow/x && flow daemon start ...
Defensive patterns
Strategy: validation
Validate before calling
// before daemonize()/open_log_file(file)
let dir = std::path::Path::new(file).parent().ok_or("log path has no parent")?;
std::fs::create_dir_all(dir)?;
let f = std::fs::OpenOptions::new().create(true).append(true).open(file)?;
drop(f); // proves the real open will succeed Try / catch
match flow_server::server_daemon::try_open_log_file(file) {
Ok(f) => f,
Err(e) => {
eprintln!("cannot open log, falling back to stderr logging: {e}");
// fall back or abort with a clean message instead of the panic
return Err(e);
}
} Prevention
- Pre-create and chown the log directory in your service unit before starting the daemon.
- Run the daemon as the user that owns the temp dir; avoid sudo/non-sudo mixes.
- Clean up stale .old logs and root-owned files during provisioning.
- Alert on temp-dir disk usage; append-mode opens fail when the volume is full or read-only.
When it happens
Trigger: daemonize()/open_log_file() running when the log path's directory does not exist, the daemon user cannot write there, the path component is a directory, SELinux/AppArmor denies the append, or the filesystem is full/read-only.
Common situations: TMPDIR or the temp_dir option pointing to a deleted directory; running the daemon under a different user than the one that created the temp dir; root-owned log files left behind by a previous sudo run; read-only container mounts; full disks.
Related errors
- fd_of_path: mkdir_no_fail({:?}): {}
- fd_of_path: open({:?}): {}
- mkdir_no_fail({:?}): {}
- failed to create {}: {}
- mkdirp: mkdir {} failed: {}
AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20).
Data as JSON: /api/errors/3a48185c7c1255a1.
Report an issue: GitHub.