{"record":{"id":"e8495c1e1346d12b","repo":"PRQL/prql","slug":"failed-to-compile","errorCode":null,"errorMessage":"failed to compile","messagePattern":"failed to compile","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/cli/watch.rs","lineNumber":125,"sourceCode":"        // file may not exist, because this may have been a delete event\n        return Ok(());\n    };\n    if prql_string.is_empty() {\n        return Ok(());\n    }\n\n    // pre-process Jinja\n    let (prql_string, jinja_context) = jinja::pre_process(&prql_string)?;\n\n    // compile\n    println!(\"Compiling {}\", prql_path.display());\n    let sql_string = match prqlc::compile(&prql_string, opt) {\n        Ok(sql_string) => sql_string,\n        Err(errs) => {\n            for err in errs.inner {\n                println!(\"{err}\");\n            }\n            return Err(anyhow!(\"failed to compile\"));\n        }\n    };\n\n    // post-process Jinja\n    let sql_string = jinja::post_process(&sql_string, jinja_context);\n\n    // write\n    fs::write(sql_path, sql_string)?;\n\n    Ok(())\n}\n","sourceCodeStart":107,"sourceCodeEnd":137,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/cli/watch.rs#L107-L137","documentation":"In watch mode, `compile_path` compiles a PRQL file and prints each diagnostic; when `prqlc::compile` returns errors it collapses them into a generic anyhow error. The detailed messages were already printed to stdout; this error propagates the failure up so the watcher keeps the file marked as failed.","triggerScenarios":"Saving a watched `.prql` file that fails to compile (syntax, semantic, or target/dialect errors).","commonSituations":"Live-editing a query and introducing a typo; watch session started against a file with errors; schema/table references not available to the compiler.","solutions":["Fix the PRQL syntax/semantics using the printed diagnostics above the error","Run `prqlc compile <file>` once (without watch) to see full error spans","Verify the query compiles before enabling the watcher"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"match prqlc::compile(&src, opt) { Ok(sql) => sql, Err(errs) => { print_all(&errs.inner); return Err(anyhow!(\"failed to compile\")); } }","preventionTips":["Fix reported diagnostics before saving in watch sessions","Run a one-off `prqlc compile <file>` for full error spans","Keep a compiling baseline and commit small query edits incrementally"],"tags":["watch","compilation","prql"],"backgroundTag":"sql-query-failed","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}