spacedriveapp/spacedrive · error · anyhow::Error
Path is required in non-interactive mode
Error message
Path is required in non-interactive mode
What it means
Thrown by LocationAddArgs::build_sd_path() when the --path argument is None. The CLI uses path absence as the signal for interactive mode (is_interactive() returns self.path.is_none()), so calling build_sd_path() without a path means a non-interactive caller asked for a path it never supplied.
Source
Thrown at apps/cli/src/domains/location/args.rs:44
/// If not provided, enters interactive mode
pub path: Option<String>,
/// Display name for the location
#[arg(long)]
pub name: Option<String>,
/// Indexing mode
#[arg(long, value_enum)]
pub mode: Option<IndexModeArg>,
}
impl LocationAddArgs {
/// Build an SdPath from the args (non-interactive mode)
pub fn build_sd_path(&self) -> anyhow::Result<SdPath> {
let path_str = self
.path
.as_ref()
.ok_or_else(|| anyhow::anyhow!("Path is required in non-interactive mode"))?;
// Use SdPath::from_uri() to parse service-based paths or local paths
SdPath::from_uri(path_str).map_err(|e| anyhow::anyhow!("Invalid path: {}", e))
}
/// Check if interactive mode should be triggered
pub fn is_interactive(&self) -> bool {
self.path.is_none()
}
}
#[derive(Args, Debug)]
pub struct LocationRemoveArgs {
pub location_id: Uuid,
#[arg(long, short = 'y', default_value_t = false)]
pub yes: bool,
}
View on GitHub (pinned to 6dfeccf211)
Solutions
- Pass --path <path-or-uri> when invoking location add non-interactively
- If you want the prompts, run the command without --path so the interactive flow starts
- When calling build_sd_path() from code, branch on is_interactive() first
Example fix
// before
let sd_path = args.build_sd_path()?; // bails when path is None
// after
let sd_path = if args.is_interactive() {
run_interactive_location_add(ctx).await?
} else {
args.build_sd_path()?
}; Defensive patterns
Strategy: validation
Validate before calling
if !args.is_interactive() {
anyhow::ensure!(args.path.is_some(), "--path is required for non-interactive location add");
}
let sd_path = args.build_sd_path()?; Type guard
impl LocationAddArgs {
fn has_path(&self) -> bool {
self.path.is_some()
}
} Prevention
- Always pass --path in scripts/CI; omit it only when you want the interactive prompts
- Check is_interactive() before build_sd_path() when calling programmatically
- Let clap enforce it instead: mark path as required unless a --interactive flag is set
When it happens
Trigger: Running the non-interactive 'sd location add' code path without --path; or code calling build_sd_path() directly without first checking is_interactive(). In the CLI's own flow this fires when a script/subcommand expects a path and none was given.
Common situations: CI or shell scripts calling 'sd location add' while forgetting --path; typos in the flag name so clap leaves it None; reusing LocationAddArgs programmatically in tests or tools.
Related errors
- Path must be a directory: {}
- Invalid instance name: {}
- Failed to build action: {}
- Invalid path: {}
- Path does not exist: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/b6be9ac355d1796b.
Report an issue: GitHub.