gitbutlerapp/gitbutler · error
' ' is not a directory
Error message
'{src}' is not a directory What it means
`but-feedback` zips a directory (repository or logs) for bug reports. Before creating the archive it checks that the source path is actually a directory; if not (missing path, a file, or a dangling symlink), it bails with the path in the message.
Solutions
- Check the path exists and is a directory before calling: std::path::Path::new(src).is_dir()
- Create the directory if it legitimately should exist (e.g. create the logs dir before zipping)
- Correct the configured repository/logs path in the caller
Example fix
// before
create_zip_file_from_dir("/maybe/missing/logs", out).await?;
// after
if !Path::new("/maybe/missing/logs").is_dir() {
std::fs::create_dir_all("/maybe/missing/logs")?;
}
create_zip_file_from_dir("/maybe/missing/logs", out).await?; Defensive patterns
Strategy: validation
Validate before calling
let src = Path::new(src_dir);
if !src.is_dir() {
return Err(anyhow!("source '{}' is not a directory", src.display()));
} Type guard
fn is_zipable_dir(p: &Path) -> bool { p.is_dir() } Try / catch
match create_zip_file_from_dir(&src, &dst).await {
Ok(path) => println!("zip at {}", path.display()),
Err(e) if e.to_string().contains("is not a directory") => {
std::fs::create_dir_all(&src)?;
// retry once
}
Err(e) => return Err(e),
} Prevention
- Ensure the logs/repository directories exist before zipping
- Resolve and canonicalize paths before passing them in
- Never pass a file path where a directory is expected
When it happens
Trigger: Calling create_zip_file_from_dir (directly or via zip_entire_repository / zip_logs) with a src_dir path that does not exist or points to a regular file instead of a directory.
Common situations: Logs directory not yet created on a fresh install; repository path moved or deleted before zip; passing a file path instead of a directory; wrong workspace root configured.
Related errors
- project path is not a directory
- Cannot attempt to open anything but a directory
- CLI destination must be absolute
- CLI source path must be absolute
- not a git repository
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/a1e42b98f4e36a3a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-feedback/src/zip.rs:21
io::{self, Read, Write},
path,
path::{Path, PathBuf},
};
use anyhow::{Result, bail};
use walkdir::{DirEntry, WalkDir};
use zip::{CompressionMethod, ZipWriter, write::SimpleFileOptions};
/// Create a zip file from the *contents* of `src_dir` and write the zip file out to `dst_file`,
/// possibly overwriting it if it exists.
pub fn create_zip_file_from_dir(
src_dir: impl AsRef<Path>,
dst_file: impl AsRef<Path>,
) -> anyhow::Result<PathBuf> {
let src_dir = src_dir.as_ref();
let dst_file = dst_file.as_ref();
if !src_dir.is_dir() {
bail!("'{src}' is not a directory", src = src_dir.display());
}
let file = fs::File::create(dst_file)?;
zip_dir(
&mut WalkDir::new(src_dir).into_iter().filter_map(Result::ok),
src_dir,
file,
)?;
Ok(dst_file.to_owned())
}
/// Create a zip file with `src` content in a single-file archive, with the file named `src_file_name`,
/// and write the zip file out to `dst_file`, possibly overwriting it if it exists.
pub fn create_zip_file_from_content(
src: &str,
src_file_name: &str,
dst_file: impl AsRef<Path>,View on GitHub (pinned to 58e5313667)