spacedriveapp/spacedrive · info · anyhow::Error
Aborted by user
Error message
Aborted by user
What it means
confirm() prints a '[y/N]' prompt and accepts only 'y' or 'yes' (case-insensitive) as consent; anything else, including empty input and EOF, bails with 'Aborted by user'. This is deliberate control flow for destructive commands ('sd stop --reset', library deletion), not a malfunction.
Source
Thrown at apps/cli/src/util/confirm.rs:31
|| std::env::var("SD_CLI_YES")
.map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
.unwrap_or(false)
{
return Ok(());
}
use std::io::{self, Write};
let mut stderr = io::stderr();
writeln!(stderr, "{} [y/N]: ", prompt)?;
stderr.flush()?;
let mut input = String::new();
io::stdin().read_line(&mut input)?;
let resp = input.trim().to_ascii_lowercase();
if resp == "y" || resp == "yes" {
Ok(())
} else {
anyhow::bail!("Aborted by user")
}
}
/// Prompt the user for a multiple-choice selection.
/// Returns the 0-based index of the selected choice.
pub fn prompt_for_choice(request: ConfirmationRequest) -> Result<usize> {
use std::io::{self, Write};
println!("{}", request.message);
for (i, choice) in request.choices.iter().enumerate() {
println!(" [{}]: {}", i + 1, choice);
}
loop {
print!("Please select an option (1-{}): ", request.choices.len());
io::stdout().flush()?;
let mut input = String::new();View on GitHub (pinned to 6dfeccf211)
Solutions
- Re-run the command and answer 'y' if you actually want the action
- In scripts, pre-feed consent only when intended: printf 'y\n' | sd stop --reset
- Treat the non-zero exit as cancellation and skip retry logic
Example fix
# before: script hangs or aborts at prompt sd stop --reset # after: explicit consent for automation printf 'y\n' | sd stop --reset
Defensive patterns
Strategy: try-catch
Validate before calling
#!/usr/bin/env bash # Non-interactive: decide before prompting if [ "$ASSUME_YES" = 1 ]; then printf 'y\n' | sd stop --reset else sd stop --reset # interactive; expect possible abort fi
Try / catch
match confirm(prompt) {
Ok(()) => { /* proceed with destructive action */ }
Err(e) if e.to_string() == "Aborted by user" => {
println!("Cancelled; no changes were made.");
std::process::exit(130); // 128+SIGINT convention for user interrupt
}
Err(e) => return Err(e), // real IO failure, e.g. broken stdin
} Prevention
- Treat 'Aborted by user' as a success-path cancellation with a distinct exit code, not an error
- Never feed blind 'yes' into prompts in scripts; gate consent behind an explicit flag
- When stdin is not a TTY, skip prompting and require a --yes/--force flag instead
When it happens
Trigger: Answering 'n', pressing Enter on the default No, piping a script into sd so stdin is at EOF, or answering 'Y ' with unexpected characters.
Common situations: Automating destructive commands without providing consent; users changing their mind at the confirmation.
Related errors
- Invalid sort option: {}. Valid options are: name, modified,
- Failed to build action: {}
- Operation aborted by user
- Invalid choice selected
- Non-local address not supported for indexing yet: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/1300d2d834024886.
Report an issue: GitHub.