zeroclaw-labs/zeroclaw · error · anyhow::Error
PowerShell Get-Content exited with non-zero status
Error message
PowerShell Get-Content exited with non-zero status
What it means
In follow mode, logs_windows shells out to PowerShell 'Get-Content -Tail N -Wait' against the resolved log file. A non-zero PowerShell exit is propagated as this error; follow mode otherwise blocks, so failure means the cmdlet could not open or keep reading the file.
Source
Thrown at crates/zeroclaw-runtime/src/service/mod.rs:1072
logs_dir.display()
);
};
if follow {
// Windows: use PowerShell Get-Content -Wait for tail -f equivalent
let status = Command::new("powershell")
.args([
"-Command",
&format!(
"Get-Content -Path '{}' -Tail {} -Wait",
log_file.display().to_string(),
lines
),
])
.status()
.context("Failed to run PowerShell Get-Content")?;
if !status.success() {
bail!("PowerShell Get-Content exited with non-zero status");
}
} else {
let status = Command::new("powershell")
.args([
"-Command",
&format!(
"Get-Content -Path '{}' -Tail {}",
log_file.display().to_string(),
lines
),
])
.status()
.context("Failed to run PowerShell Get-Content")?;
if !status.success() {
bail!("PowerShell Get-Content exited with non-zero status");
}
}
Ok(())View on GitHub (pinned to 88bb9c8533)
Solutions
- Re-run 'zeroclaw service logs' after the lock or rotation clears
- Test manually: powershell -Command "Get-Content -Tail 50 -Wait '<logfile>'" to see the cmdlet error
- Fix ACLs or move the log directory to a path without spaces/special characters
Defensive patterns
Strategy: try-catch
Validate before calling
if !log_file.exists() {
// avoid spawning PowerShell for a file that is already gone
} Try / catch
match service::logs(&config, init, lines, true) {
Err(err) if err.to_string().contains("PowerShell Get-Content exited with non-zero status") => {
// likely a lock or rotation: advise retry, fall back to a non-following read
let _ = service::logs(&config, init, lines, false);
}
result => result?,
} Prevention
- Keep the Windows log path free of spaces and special characters
- Coordinate log rotation so it does not overlap follow-mode reads
- Grant the reading user ACL access to the log directory
When it happens
Trigger: The log file is locked by another process, deleted or rotated between resolution and the Get-Content spawn, unreadable due to ACLs, or the constructed -Command string hits a path with problematic quoting.
Common situations: Log rotation while following on Windows; files locked by the daemon or backup/antivirus software; paths containing spaces or quotes breaking the inner PowerShell command line.
Related errors
- tail exited with non-zero status
- journalctl exited with non-zero status
- Edge TTS subprocess timed out
- edge-tts failed (exit {}): {}
- Cannot determine current username; ACL hardening is required
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/1299d804958e2274.
Report an issue: GitHub.