gitbutlerapp/gitbutler · error · anyhow::Error

Invalid value '{value}'. Use true/false or 1/0.

Error message

Invalid value '{value}'. Use true/false or 1/0.

What it means

For `but config ui set <key> <value>`, the value is parsed by gix::config::Boolean::try_from before being written to Git config as 'true'/'false'. The error (attached via with_context to the parse failure) means the string is not a recognized boolean spelling — gix accepts the standard Git set (true/false/1/0/yes/no/on/off, case-insensitive); anything else, including 'enabled', 'y', 'TRUE ' with spaces or 'false,true', fails. The context message itself recommends true/false or 1/0.

Source

Thrown at crates/but/src/command/config.rs:2073

                writeln!(
                    out,
                    "  {}",
                    t.command_suggestion.paint("but config ui set tui true")
                )?;
                writeln!(
                    out,
                    "  {}",
                    t.command_suggestion.paint("but config ui set tui false")
                )?;
            } else if let Some(out) = out.for_json() {
                out.write_value(serde_json::json!({ "tui": tui_enabled }))?;
            }
        }
        Some(UiSubcommand::Set { key, value, global }) => {
            let git_key = key.to_git_key();
            let bool_value = gix::config::Boolean::try_from(value.as_bytes().as_bstr())
                .with_context(|| {
                    anyhow::anyhow!("Invalid value '{value}'. Use true/false or 1/0.")
                })?
                .0;
            let serialized = if bool_value { "true" } else { "false" };
            edit_git_config(&repo, global.into(), |config| {
                set_config_value(config, git_key, serialized)?;
                Ok(())
            })?;

            if let Some(out) = out.for_human() {
                writeln!(
                    out,
                    "{} Set {} {} {}",
                    t.sym().success,
                    t.config_key.paint(git_key),
                    t.hint.paint("→"),
                    if bool_value {
                        t.config_value.paint("true")
                    } else {

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Use exactly true or false (or 1/0): `but config ui set tui false`.
  2. Trim whitespace and remove shell quotes so the parser sees a bare word.
  3. If you need arbitrary values, note this subcommand only accepts booleans — write other value types directly with `git config`.

Example fix

# before
$ but config ui set tui "false "   # trailing space
Error: Invalid value 'false '. Use true/false or 1/0.

# after
$ but config ui set tui false
Defensive patterns

Strategy: validation

Validate before calling

// Validate before invoking the CLI
fn parse_bool(value: &str) -> Option<bool> {
    gix::config::Boolean::try_from(value.as_bytes().as_bstr()).ok().map(|b| b.0)
}
if parse_bool(&value).is_none() {
    return Err(format!("Invalid value '{value}'. Use true/false or 1/0."));
}

Prevention

When it happens

Trigger: `but config ui set tui maybe`, `but config ui set tui yes please`, passing an empty string, or passing a value with surrounding quotes/spaces that reached the parser verbatim.

Common situations: Users typing natural-language booleans ('enable', 'off?' as intent), copy-pasting values with stray whitespace or smart quotes, scripts interpolating unvalidated input into the command.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/51515959c21327de. Report an issue: GitHub.