Skip to content

"debcargo failed: stream did not contain valid UTF-8" caused by vim swap file

I ran into this error a few times, I think it should provide additional context what was tried to process (in this case .with_context(|| anyhow!("Failed to read file: {path:?}"))? would've made this very obvious.

I used strace and noticed:

openat(AT_FDCWD, "/debcargo-conf/build/apt-swarm/debian/.debcargo.toml.swp", O_RDONLY|O_CLOEXEC) = 4

This file is binary and an utf-8 error is to be expected. debcargo should either not try to process these, or point out the file as problematic.

It's unfortunate Debian stores .swp files next to the file being edited, instead of the home folder like Arch Linux does.