GitoxideLabs/gitoxide · error · anyhow::Error
{err}
Error message
{err} What it means
This is a context-wrapping of an underlying object-write failure in `gix merge tree` CLI handling. After a merge produces in-memory trees, the CLI writes each tree back to the object database via `repo.write(tree)`; any write error (I/O, compression, missing object) is re-raised as `anyhow!("{err}")` losing its type but keeping the message.
Solutions
- Check disk space and write permissions on .git/objects
- Run the same operation as a user with write access to the repository
- Inspect the inner `{err}` message for the root cause from gix::odb::write
- Reproduce with a fresh clone to rule out object-store corruption
Example fix
// before
.map_err(|err| anyhow!("{err}"))?
// after
.map_err(|err| anyhow!("failed to write merged tree to object database: {err}"))? Defensive patterns
Strategy: try-catch
Validate before calling
fn can_write_objects(repo: &gix::Repository) -> bool {
repo.workdir()
.map(|d| d.join("objects").metadata().map(|m| !m.permissions().readonly()).unwrap_or(false))
.unwrap_or(false)
} Try / catch
match result {
Ok(v) => v,
Err(e) => { eprintln!("tree write failed: {e:#}"); check_disk_and_permissions(); }
} Prevention
- Check free disk space before large merge operations
- Verify .git/objects is writable in CI containers
- Prefer running merges on local, non-read-only clones
When it happens
Trigger: Calling the `gix merge tree` CLI (gitoxide-core `repository::merge::tree`) where the merge result tree cannot be written to the object database — e.g. unwritable .git/objects, disk full, or an internal gix::object::write error.
Common situations: Running merges in read-only or disk-full environments; permission issues on .git/objects; corrupted object database backends.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- could not persist a prepared rebase object
- Cannot run without any task to perform on the repositories
- At least one operation failed
- No commits to process
- Refusing to checkout index into existing directory
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/93df4ffd0e774be0.
Report an issue: GitHub.
Appendix: source
Thrown at gitoxide-core/src/repository/merge/tree.rs:103
if message.is_some() && has_unresolved_conflicts {
write_unresolved_conflict_paths(err, &res.conflicts)?;
if debug {
writeln!(err, "{:#?}", res.conflicts)?;
}
bail!("Tree conflicted, refusing to write commit");
}
let tree_id = {
let _span = gix::trace::detail!("Writing merged tree");
let mut written = 0;
let tree_id = res
.tree
.detach()
.write(|tree| {
written += 1;
repo.write(tree)
})
.map_err(|err| anyhow!("{err}"))?;
writeln!(out, "{tree_id} (wrote {written} trees)")?;
tree_id
};
let conflicts = res.conflicts;
if message.is_some() && !in_memory {
persist_in_memory_objects(&mut repo)?;
}
if let Some(message) = message {
let head_id = repo.head_id()?;
let commit_id = if update_head {
let commit_id = repo.commit("HEAD", message, tree_id, Some(head_id))?;
let mut index = repo.index_from_tree(&tree_id)?;
index.write(Default::default())?;
commit_id
} else {
repo.new_commit(message, tree_id, Some(head_id))?.id()View on GitHub (pinned to e73179060b)