jdx/mise · error

expected y/yes or n/no, got

Error message

expected y/yes or n/no, got {:?}

What it means

mise's interactive confirm prompt reads a line from stdin and accepts only 'y', 'yes', 'n', 'no' (case-insensitive prefix match). Any other non-empty answer makes parse_confirm_answer bail with this message echoing the trimmed input. It exists to force an explicit yes/no rather than guessing.

Solutions

  1. Answer with y/yes or n/no exactly at the prompt.
  2. In scripts, avoid the prompt: pipe 'y' (echo y | mise ...) or use non-interactive flags/settings (e.g. --yes / MISE_YES=1).
  3. Ensure stdin redirection actually supplies a valid answer, not unrelated file content.

Example fix

// before (CI)
mise install < some.log
// after
echo y | mise install   # or: mise install --yes
Defensive patterns

Strategy: try-catch

Validate before calling

function isConfirmAnswer(s) {
  const a = String(s).trim().toLowerCase();
  return ['y', 'yes', 'n', 'no'].some(v => v.startsWith(a) && a.length > 0);
}

Try / catch

// Rust
match read_confirm_from_stdin(default) {
    Ok(c) => c,
    Err(e) if e.to_string().contains("expected y/yes or n/no") => {
        eprintln!("Please answer y or n");
        // re-prompt or fall back to default
        default
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: read_confirm_from_stdin receiving input that is neither a y/yes nor n/no prefix — e.g. piping unexpected text into a command that prompts, typing 'ok', '1', or pasting multi-word text at the prompt.

Common situations: Automating mise (CI scripts) where stdin contains unrelated data; users typing 'Y ' with odd whitespace is fine (trimmed) but 'yeah', 'sure', or an empty-then-garbage answer fails; redirecting files into mise commands that confirm trust/install prompts.

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


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/ba9365b547d21f80. Report an issue: GitHub.

Appendix: source

Thrown at src/ui/prompt.rs:143

/// error for anything else -- silently rereading what someone typed as "no" would
/// be worse than telling them it was not understood.
///
/// `None` means stdin reached EOF without an answer -- the one case `demand`
/// gets wrong (it applies the default) and the reason this exists.
fn parse_confirm_answer(line: Option<&str>, default_yes: bool) -> eyre::Result<Confirmation> {
    let Some(line) = line else {
        return Ok(Confirmation::Unanswered);
    };
    let answer = line.trim().to_lowercase();
    if answer.is_empty() {
        return Ok(default_answer(default_yes));
    }
    if "yes".starts_with(&answer) {
        Ok(Confirmation::Yes)
    } else if "no".starts_with(&answer) {
        Ok(Confirmation::No)
    } else {
        eyre::bail!("expected y/yes or n/no, got {:?}", line.trim())
    }
}

fn default_answer(default_yes: bool) -> Confirmation {
    if default_yes {
        Confirmation::Yes
    } else {
        Confirmation::No
    }
}

pub(crate) fn confirm_with_all<S: Into<String>>(message: S) -> eyre::Result<Confirmation> {
    let _lock = MUTEX.lock().unwrap(); // Prevent multiple prompts at once
    ctrlc::show_cursor_after_ctrl_c();

    if !can_prompt_dialog() {
        return Ok(Confirmation::Unavailable);
    }

View on GitHub (pinned to 533346cc37)