{"record":{"id":"e57857cd4e7455ac","repo":"jdx/mise","slug":"stdin-reads-the-value-from-stdin-do-not-provide","errorCode":null,"errorMessage":"--stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax","messagePattern":"--stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/set.rs","lineNumber":183,"sourceCode":"                    if ev.value.is_none() {\n                        let prompt_msg = format!(\"Enter value for {}\", ev.key);\n                        let value = Input::new(&prompt_msg)\n                            .password(self.age_encrypt) // Mask input if encrypting\n                            .theme(&theme)\n                            .run()?;\n                        ev.value = Some(value);\n                    }\n                }\n            }\n\n            // Read value from stdin if requested\n            if self.stdin {\n                if env_vars.len() != 1 {\n                    bail!(\"--stdin requires exactly one environment variable key\");\n                }\n                let ev = &mut env_vars[0];\n                if ev.value.is_some() {\n                    bail!(\n                        \"--stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax\"\n                    );\n                }\n                let mut value = String::new();\n                std::io::stdin().read_to_string(&mut value)?;\n                // Strip a single trailing newline (matches `gh secret set` behavior)\n                if value.ends_with(\"\\r\\n\") {\n                    value.truncate(value.len() - 2);\n                } else if value.ends_with('\\n') {\n                    value.truncate(value.len() - 1);\n                }\n                ev.value = Some(value);\n            }\n\n            // Handle age encryption if requested\n            if self.age_encrypt {\n                Settings::get().ensure_experimental(\"age encryption\")?;\n                // Collect recipients once before the loop to avoid repeated I/O","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cli/set.rs#L165-L201","documentation":"`--stdin` and an inline value are mutually exclusive sources for the same variable. If the single key was parsed as KEY=VALUE (ev.value.is_some()), mise bails instead of silently choosing a winner, so the stdin content is never consumed or lost.","triggerScenarios":"Running `echo val | mise set --stdin FOO=bar` — one KEY=VALUE argument combined with --stdin.","commonSituations":"Copy-pasting a previous `mise set FOO=bar` command and adding --stdin; scripts templating both the value and the pipe.","solutions":["Drop the inline value and let stdin supply it: `echo bar | mise set --stdin FOO`","Or drop --stdin and set directly: `mise set FOO=bar`"],"exampleFix":"# before\necho bar | mise set --stdin FOO=bar   # --stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax\n\n# after\necho bar | mise set --stdin FOO","handlingStrategy":"validation","validationCode":"# reject KEY=VALUE arguments before invoking --stdin\ncase \"$key\" in\n  *=*) echo 'pass a bare KEY with --stdin; the value comes from stdin' >&2; exit 2;;\nesac\nprintf '%s' \"$value\" | mise set --stdin \"$key\"","typeGuard":"is_bare_key() { case \"$1\" in *=*) return 1;; *) return 0;; esac; }","tryCatchPattern":"No retry value: catch the error, strip the inline value from the command, and rerun `printf '%s' value | mise set --stdin KEY`.","preventionTips":["Treat --stdin and KEY=VALUE as mutually exclusive sources","Generate commands from templates that fill either the value or the pipe, never both"],"tags":["cli","stdin","conflicting-arguments","env","mise"],"backgroundTag":"conflicting-cli-arguments","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}