spacedriveapp/spacedrive · error · anyhow::Error
Path does not exist: {}
Error message
Path does not exist: {} What it means
Thrown by the interactive location-add flow after the user types a local path and std::path::PathBuf::exists() returns false. The wizard validates existence before creating SdPath::local(path_buf), because an indexed location must point at a real directory on disk.
Source
Thrown at apps/cli/src/domains/location/mod.rs:155
use sd_core::domain::addressing::SdPath;
use sd_core::ops::indexing::IndexMode;
println!("\n=== Add New Location ===\n");
// 1. Location type
let location_type = select(
"What type of location would you like to add?",
&["Local filesystem".to_string(), "Cloud storage".to_string()],
)?;
let sd_path = if location_type == 0 {
// Local filesystem
let path_str = text("Enter the local path", false)?.unwrap();
let path_buf = std::path::PathBuf::from(path_str);
// Validate that path exists
if !path_buf.exists() {
anyhow::bail!("Path does not exist: {}", path_buf.display());
}
if !path_buf.is_dir() {
anyhow::bail!("Path must be a directory: {}", path_buf.display());
}
SdPath::local(path_buf)
} else {
// Cloud storage
use sd_core::ops::volumes::list::VolumeListQueryInput;
let volumes: sd_core::ops::volumes::list::VolumeListOutput = execute_query!(
ctx,
VolumeListQueryInput {
filter: sd_core::ops::volumes::VolumeFilter::TrackedOnly
}
);
if volumes.volumes.is_empty() {View on GitHub (pinned to 6dfeccf211)
Solutions
- Use the absolute path with the tilde already expanded, e.g. /home/user/photos
- Create the directory first (mkdir -p) if it should exist
- Check the drive/mount is actually mounted on the machine running the daemon
- Verify with ls <path> in another terminal before re-entering it
Example fix
// before: tilde is checked literally and fails
let path_str = text("Enter the local path", false)?.unwrap();
let path_buf = std::path::PathBuf::from(path_str);
// after: expand ~ before validating
let path_str = text("Enter the local path", false)?.unwrap();
let expanded = shellexpand::tilde(&path_str).into_owned();
let path_buf = std::path::PathBuf::from(expanded); Defensive patterns
Strategy: validation
Validate before calling
let expanded = shellexpand::tilde(&path_str).into_owned();
let path_buf = std::path::PathBuf::from(&expanded);
if !path_buf.try_exists().unwrap_or(false) {
eprintln!("'{}' does not exist (tilde is NOT expanded automatically)", expanded);
return Ok(());
} Type guard
fn is_existing_dir(p: &str) -> bool {
let expanded = shellexpand::tilde(p).into_owned();
std::path::Path::new(&expanded).is_dir()
} Prevention
- Always expand ~ and $HOME before passing paths to the CLI
- Verify the mount/disk is attached on the daemon's machine, not just your shell's
- mkdir -p directories that should exist before adding them as locations
When it happens
Trigger: Typing a path with a typo, a not-yet-created directory, or an unexpanded tilde ('~/photos' is checked literally, shells do not expand it for prompts) in the 'Enter the local path' prompt.
Common situations: Tilde or environment variables ($HOME) pasted into the prompt; directory on an unmounted external drive or network mount; the directory lives on the daemon's machine but the path was written for a different machine.
Related errors
- Path must be a directory: {}
- Operation aborted by user
- No paired devices found. Pair a device first with: sd networ
- No libraries found on remote device. Use 'Share my library'
- Path is required in non-interactive mode
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/6fe7a9a785033a1d.
Report an issue: GitHub.