gitbutlerapp/gitbutler · error
Path does not exist
Error message
Path does not exist: {path} What it means
Before launching a terminal on Windows, open_in_terminal() validates the path: if the path does not exist on disk it bails with this error. Windows is the only platform branch performing this explicit existence check, since terminals there are launched with an explicit canonicalized working directory.
Solutions
- Verify the path exists (e.g. in Explorer or via existsSync / Path::new(path).exists())
- Fix the path: correct drive letter and separators, ensure network drives are mounted
- Re-open the project from its current location so stored paths refresh
Example fix
// before
open_in_terminal("powershell", "C:\\repos\\old-name") // deleted
// after
open_in_terminal("powershell", "C:\\repos\\new-name") Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
function safeTerminalPath(p: string): string | null {
return existsSync(p) ? p : null;
} Type guard
fn is_existing_path(p: &str) -> bool { Path::new(p).exists() } Prevention
- Check the path exists before calling open_in_terminal on Windows
- Refresh stored project paths after moves/renames
- Ensure network drives are mounted before launching terminals in them
When it happens
Trigger: Calling open_in_terminal on Windows with a path string pointing to a non-existent directory (deleted project, wrong drive letter, UNC typo).
Common situations: Stale project paths after a repo move/rename, mistyped drive letters, network drives not mounted, or WSL-style paths (/home/...) passed to the Windows branch.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- CLI destination must be absolute
- CLI source path must be absolute
- not a git repository
- Path is not a directory
- project path is not a directory
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/ccffc1d46f2df52a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/open/mod.rs:536
};
} else if cfg!(windows) {
#[cfg(windows)]
fn create_new_console(cmd: &mut Command) -> &mut Command {
use std::os::windows::process::CommandExt;
// CREATE_NEW_CONSOLE: Creates a new console for the process (0x00000010)
// This allows the terminal to run independently without blocking our thread
const CREATE_NEW_CONSOLE: u32 = 0x00000010;
cmd.creation_flags(CREATE_NEW_CONSOLE)
}
#[cfg(not(windows))]
fn create_new_console(cmd: &mut Command) -> &mut Command {
cmd
}
// Validate path exists and canonicalize it to proper Windows format
let path_buf = Path::new(&path);
if !path_buf.exists() {
bail!("Path does not exist: {path}");
}
if !path_buf.is_dir() {
bail!("Path is not a directory: {path}");
}
// Canonicalize to get the absolute, properly formatted Windows path
// This converts forward slashes to backslashes and resolves . and ..
let canonical_path = gix::path::realpath(path_buf)
.with_context(|| format!("Failed to canonicalize path: {path}"))?
.to_str()
.context("BUG: input path is String, should be able to convert back to it")?
.to_owned();
let canonical_path = &canonical_path;
// Check if the terminal binary exists in PATH before attempting to launch.
let binary_found = which::which(&terminal_id).is_ok();
if !binary_found {
return Err(anyhow::anyhow!("'{terminal_id}' was not found.")View on GitHub (pinned to 58e5313667)