PRQL/prql · error · anyhow::Error
debug log was started, but it cannot be found after…
Error message
debug log was started, but it cannot be found after compilation
What it means
`write_log` serializes the debug log accumulated during compilation. The log is started via a debug flag and collected at `log_finish()`; if compilation never started (or already consumed) the log, `log_finish` returns None and this error is raised. It signals a mismatch between the debug-logging lifecycle and the write step.
Solutions
- Make sure debug logging is initialized (debug::log / the debug flag) before compilation runs
- Call write_log only once per compilation
- If it reproduces in normal CLI use, file a bug with the command line
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
if let Some(log) = debug::log_finish() { write_log(&path, log)?; } else { eprintln!("debug log unavailable"); } Prevention
- Initialize debug logging once before compilation and finish it exactly once
- Wrap log-start/finish in a guard type
- Only request --debug-log output when logging was enabled
When it happens
Trigger: Calling the CLI with a `--debug-log` style path but the debug log was never initialized (e.g. `debug::log` not started before compilation, or finish already called once).
Common situations: Invoking `execute` programmatically without calling the log-init step; calling `write_log` twice; a compiler bug where the log was dropped mid-compilation.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- internal error: command does not take input & output
- unknown debug log format for file
- Crate is not built with the `cli` feature enabled, or was…
- Currently `lex` only works with a single source, but found…
- Currently `annotate` only works with a single source, but…
AI-assisted analysis of PRQL/prql@e164e249b9 (2026-09-09).
Data as JSON: /api/errors/7befa0a734c59c3c.
Report an issue: GitHub.
Appendix: source
Thrown at prqlc/prqlc/src/cli/mod.rs:582
Ok(output.write_all(data)?)
}
}
fn has_debug_log(cli: &Cli) -> bool {
matches!(
cli.command,
Some(Command::Compile {
debug_log: Some(_),
..
})
)
}
pub fn write_log(path: &std::path::Path) -> Result<()> {
let debug_log = if let Some(debug_log) = debug::log_finish() {
debug_log
} else {
return Err(anyhow!(
"debug log was started, but it cannot be found after compilation"
));
};
match path.extension().and_then(|s| s.to_str()) {
Some("json") => {
let file = BufWriter::new(File::create(path)?);
serde_json::to_writer(file, &debug_log)?;
}
Some("html") => {
let file = BufWriter::new(File::create(path)?);
debug::render_log_to_html(file, &debug_log)?;
}
_ => {
return Err(anyhow!("unknown debug log format for file {path:?}"));
}
}
Ok(())
}View on GitHub (pinned to e164e249b9)