{"record":{"id":"1299d804958e2274","repo":"zeroclaw-labs/zeroclaw","slug":"powershell-get-content-exited-with-non-zero-status","errorCode":null,"errorMessage":"PowerShell Get-Content exited with non-zero status","messagePattern":"PowerShell Get-Content exited with non-zero status","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/service/mod.rs","lineNumber":1072,"sourceCode":"            logs_dir.display()\n        );\n    };\n\n    if follow {\n        // Windows: use PowerShell Get-Content -Wait for tail -f equivalent\n        let status = Command::new(\"powershell\")\n            .args([\n                \"-Command\",\n                &format!(\n                    \"Get-Content -Path '{}' -Tail {} -Wait\",\n                    log_file.display().to_string(),\n                    lines\n                ),\n            ])\n            .status()\n            .context(\"Failed to run PowerShell Get-Content\")?;\n        if !status.success() {\n            bail!(\"PowerShell Get-Content exited with non-zero status\");\n        }\n    } else {\n        let status = Command::new(\"powershell\")\n            .args([\n                \"-Command\",\n                &format!(\n                    \"Get-Content -Path '{}' -Tail {}\",\n                    log_file.display().to_string(),\n                    lines\n                ),\n            ])\n            .status()\n            .context(\"Failed to run PowerShell Get-Content\")?;\n        if !status.success() {\n            bail!(\"PowerShell Get-Content exited with non-zero status\");\n        }\n    }\n    Ok(())","sourceCodeStart":1054,"sourceCodeEnd":1090,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/service/mod.rs#L1054-L1090","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if !log_file.exists() {\n    // avoid spawning PowerShell for a file that is already gone\n}","typeGuard":null,"tryCatchPattern":"match service::logs(&config, init, lines, true) {\n    Err(err) if err.to_string().contains(\"PowerShell Get-Content exited with non-zero status\") => {\n        // likely a lock or rotation: advise retry, fall back to a non-following read\n        let _ = service::logs(&config, init, lines, false);\n    }\n    result => result?,\n}","preventionTips":["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"],"tags":["windows","powershell","logs","follow","subprocess"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}