BoundaryML/baml · error · std::io::Error
Parse error
Error message
Parse error: {e} What it means
The stow tool reloads a Cargo.toml document from disk after applying fixes and parses it with toml_edit. If parsing fails, the toml error is wrapped into an std::io::Error of kind InvalidData with the message "Parse error: {e}". This means the file on disk is not valid TOML (or has constructs toml_edit rejects) at reload time.
Solutions
- Open the Cargo.toml at the reported path and fix the TOML syntax error cited by the inner message.
- Restore the file from git (git checkout -- Cargo.toml) if a stow write corrupted it.
- Re-run the stow command after fixing so the reload succeeds.
- Check for concurrent processes editing the same manifest and retry after they finish.
Defensive patterns
Strategy: try-catch
Validate before calling
let content = std::fs::read_to_string("Cargo.toml")?;\ntoml::from_str::<toml::Value>(&content).expect("Cargo.toml is not valid TOML before running stow"); Try / catch
match result {\n Err(e) if e.kind() == std::io::ErrorKind::InvalidData && e.to_string().starts_with("Parse error") => {\n eprintln!("{cargo_path} is invalid TOML: {e}; restore from git");\n }\n other => other?,\n} Prevention
- Run `cargo check` (which parses manifests) before stow passes.
- Avoid manual edits to manifests while tooling runs.
- Restore manifests with `git checkout -- Cargo.toml` after failed runs.
- Keep files BOM-free UTF-8.
When it happens
Trigger: reload() reads self.cargo_path and calls content.parse::<DocumentMut>(); any toml_edit parse failure — after the tool wrote edits or another process modified the file — triggers this error.
Common situations: A previous partially-failed write left truncated TOML; manual edits during the run introduced syntax errors; duplicate keys introduced by concurrent tooling; leftover merge-conflict markers in the manifest.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- ExposedError (formatted via format_last_error_with_details)
- Failed to parse float
- Failed to parse JSON response
- Invalid checksum file format
- No parsed value
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/a44b5b863bbe1c9e.
Report an issue: GitHub.
Appendix: source
Thrown at baml_language/crates/tools_stow/src/main.rs:540
let folder_name = crate_dir.file_name()?.to_string_lossy().into_owned();
let content = std::fs::read_to_string(&cargo_path).ok()?;
let doc: DocumentMut = content.parse().ok()?;
let crate_name = extract_crate_name(&doc, &folder_name).to_owned();
Some(CrateInfo {
cargo_path,
folder_name,
crate_name,
doc,
})
}
/// Reload the document from disk (after fixes).
fn reload(&mut self) -> std::io::Result<()> {
let content = std::fs::read_to_string(&self.cargo_path)?;
self.doc = content.parse().map_err(|e| {
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("Parse error: {e}"))
})?;
self.crate_name = extract_crate_name(&self.doc, &self.folder_name).to_owned();
Ok(())
}
}
struct ManifestSelection {
root_dir: PathBuf,
manifest_path: PathBuf,
is_workspace: bool,
}
fn find_best_manifest() -> Option<ManifestSelection> {
let mut dir = std::env::current_dir().ok()?;
let mut fallback_manifest: Option<PathBuf> = None;
loop {
let cargo_toml = dir.join("Cargo.toml");View on GitHub (pinned to bd85ce9dee)