jdx/mise · error

--stdin requires exactly one environment variable key

Error message

--stdin requires exactly one environment variable key

What it means

`mise set --stdin KEY` reads the variable's value from standard input, so it accepts exactly one KEY argument (without =value). If zero or multiple keys are given, mise cannot know which variable the piped value belongs to and bails.

Solutions

  1. Pass exactly one key: `echo secret | mise set --stdin API_KEY`
  2. Set multiple variables in separate invocations without --stdin
  3. Omit --stdin and use KEY=VALUE form for multiple variables

Example fix

// before
mise set --stdin KEY1 KEY2   # error
// after
echo secret | mise set --stdin KEY1
Defensive patterns

Strategy: validation

Validate before calling

[[ $# -eq 1 ]] || { echo 'usage: echo value | mise set --stdin KEY'; exit 1; }

Prevention

When it happens

Trigger: `mise set --stdin` with no keys; `mise set --stdin KEY1 KEY2`; passing multiple assignments with --stdin.

Common situations: Scripting value injection from files/secrets managers while accidentally passing several keys; forgetting the key argument entirely.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/cli/set.rs:188

            // Prompt for values if requested
            if self.prompt {
                let theme = crate::ui::theme::get_theme();
                for ev in &mut env_vars {
                    if ev.value.is_none() {
                        let prompt_msg = format!("Enter value for {}", ev.key);
                        let value = Input::new(&prompt_msg)
                            .password(self.age_encrypt) // Mask input if encrypting
                            .theme(&theme)
                            .run()?;
                        ev.value = Some(value);
                    }
                }
            }

            // Read value from stdin if requested
            if self.stdin {
                if env_vars.len() != 1 {
                    bail!("--stdin requires exactly one environment variable key");
                }
                let ev = &mut env_vars[0];
                if ev.value.is_some() {
                    bail!(
                        "--stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax"
                    );
                }
                let mut value = String::new();
                std::io::stdin().read_to_string(&mut value)?;
                // Strip a single trailing newline (matches `gh secret set` behavior)
                if value.ends_with("\r\n") {
                    value.truncate(value.len() - 2);
                } else if value.ends_with('\n') {
                    value.truncate(value.len() - 1);
                }
                ev.value = Some(value);
            }

View on GitHub (pinned to 533346cc37)