GitoxideLabs/gitoxide · error
does not exist.
Error message
{path:?} does not exist. What it means
`is_path_owned_by_current_user` first requires the path to exist; on Windows (and generally) if `path.exists()` is false it returns an io::Error of kind NotFound: "{path:?} does not exist.". The ownership check is undefined for non-existent files, so it fails fast instead of guessing.
Solutions
- Verify the path exists before calling (std::path::Path::exists or create the file first)
- Check the path spelling and that the file wasn't removed concurrently
- Re-create the missing config/hook file, or point the check at an existing path
- If the path is optional, handle NotFound gracefully instead of treating it as a trust failure
Example fix
// before
let owned = gix_sec::trust::is_path_owned_by_current_user(&cfg_path)?;
// after
if cfg_path.exists() {
let owned = gix_sec::trust::is_path_owned_by_current_user(&cfg_path)?;
} else {
// treat as absent config, skip trust check
} Defensive patterns
Strategy: validation
Validate before calling
if !path.as_ref().exists() {
return Err(anyhow::anyhow!("skipping trust check: {:?} missing", path));
} Prevention
- Always check existence before ownership checks
- Handle files deleted between discovery and check (TOCTOU)
- Re-create default config files rather than checking trust of missing paths
When it happens
Trigger: Calling `gix_sec::trust::is_path_owned_by_current_user(path)` (or higher-level trust checks in gix that call it) with a path that has been deleted, renamed, or was never created.
Common situations: Config file or hook path deleted between discovery and ownership check; typo'd path passed directly; race where another process removes the file; running against a template path not yet materialized.
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
- path does not name a file
- Removal target ' ' must be contained in boundary
- {}: {}
- present and consumed once
- present and consumed once
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/977655099c997b66.
Report an issue: GitHub.
Appendix: source
Thrown at gix-sec/src/identity.rs:170
}
Ok(info.assume_init())
}
}
pub fn is_path_owned_by_current_user(path: &Path) -> io::Result<bool> {
use windows_sys::Win32::{
Foundation::{ERROR_INVALID_FUNCTION, ERROR_SUCCESS, LocalFree},
Security::{
Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT},
CheckTokenMembership, EqualSid, IsWellKnownSid, OWNER_SECURITY_INFORMATION, PSECURITY_DESCRIPTOR,
TOKEN_ELEVATION_TYPE, TOKEN_LINKED_TOKEN, TOKEN_QUERY, TOKEN_USER, TokenElevationType,
TokenElevationTypeLimited, TokenLinkedToken, TokenUser, WinBuiltinAdministratorsSid,
},
System::Threading::{GetCurrentProcess, GetCurrentThread, OpenProcessToken, OpenThreadToken},
};
if !path.exists() {
return Err(io::Error::new(
io::ErrorKind::NotFound,
format!("{path:?} does not exist."),
));
}
// Home is not actually owned by the corresponding user
// but it can be considered de-facto owned by the user
// Ignore errors here and just do the regular checks below
if gix_path::realpath(path).ok() == gix_path::env::home_dir() {
return Ok(true);
}
#[expect(unsafe_code)]
unsafe {
let (folder_owner, descriptor) = {
let mut folder_owner = MaybeUninit::uninit();
let mut pdescriptor = MaybeUninit::uninit();
let result = GetNamedSecurityInfoW(View on GitHub (pinned to e73179060b)