Morganamilo/paru · error
unknown mode
Error message
unknown mode {} What it means
`Mode::from_str` builds a bitmask mode from a character string; any character other than 'a' (AUR), 'r' (repo), or 'p' (pkgbuild) causes a bail with 'unknown mode {}'. The full input string is reported even though the offending char caused it.
Solutions
- Use only the characters a, r, p (e.g. `Mode = arp` for all modes)
- Remove the invalid character from the mode string
- Check the docs: the mode string is a set of initials, not words
Example fix
// before Mode = aur // after Mode = a // or "ar" for aur+repo
Defensive patterns
Strategy: validation
Validate before calling
function validate_mode(input: string): string | null {
return /^[arp]*$/.test(input) ? null : `unknown mode '${input}': only chars a, r, p are allowed`;
} Type guard
function isValidMode(v: string): v is '' | 'a' | 'r' | 'p' | 'ar' | 'ap' | 'rp' | 'arp' {
return /^[arp]*$/.test(v);
} Try / catch
match Mode::from_str(input) {
Err(e) if e.to_string().contains("unknown mode") => {
eprintln!("{} — use initials: a=AUR, r=repo, p=pkgbuild (e.g. Mode = arp)", e);
std::process::exit(1);
}
Err(e) => return Err(e),
Ok(m) => apply(m),
} Prevention
- Remember Mode takes initials (a/r/p), not full words like 'aur'
- Sanitize the mode string from environment/config before parsing
- Prefer the explicit single-char form in shared configs
When it happens
Trigger: Setting a mode option to a string containing invalid characters, e.g. `Mode = abc` ('b' is invalid), `Mode = aur` (full word instead of initials), or `Mode = arz`.
Common situations: Users writing 'aur'/'repo' instead of the single letters a/r/p in paru.conf; typos in the mode string; copying mode values from other tools.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid value ' ' for key ' ', expected
- section can not be called
- no local repo named
- key can not contain null bytes
- value can not contain null bytes
AI-assisted analysis of Morganamilo/paru@9ac3578807 (2026-09-12).
Data as JSON: /api/errors/54367f6f34b5a5cb.
Report an issue: GitHub.
Appendix: source
Thrown at src/config.rs:332
}
impl FromStr for Mode {
type Err = Error;
fn from_str(input: &str) -> Result<Self> {
let mode = match input {
"all" => Mode::all(),
"aur" => Mode::AUR,
"repo" => Mode::REPO,
"pkgbuilds" => Mode::PKGBUILD,
_ => {
let mut mode = Mode::empty();
for c in input.chars() {
match c {
'a' => mode |= Mode::AUR,
'r' => mode |= Mode::REPO,
'p' => mode |= Mode::PKGBUILD,
_ => bail!(tr!("unknown mode {}", input)),
}
}
mode
}
};
Ok(mode)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum YesNoAll {
Yes,
No,
All,
}
impl ConfigEnum for YesNoAll {
const VALUE_LOOKUP: ConfigEnumValues<Self> =View on GitHub (pinned to 9ac3578807)