{"record":{"id":"9adae16e9c4ee044","repo":"jdx/mise","slug":"tool-option-key-was-specified-more-than-once-f","errorCode":null,"errorMessage":"tool option {key:?} was specified more than once for {}","messagePattern":"tool option (.+?) was specified more than once for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/use.rs","lineNumber":210,"sourceCode":"        for option in &self.tool_option {\n            let (key, value) = option\n                .split_once('=')\n                .ok_or_else(|| eyre!(\"--tool-option expects KEY=VALUE: {option}\"))?;\n            let key = key.trim();\n            if key.is_empty() {\n                bail!(\"--tool-option requires a non-empty key\");\n            }\n            let value = toml::from_str::<toml::Table>(&format!(\"value = {value}\"))\n                .ok()\n                .filter(|table| table.len() == 1)\n                .and_then(|mut table| table.remove(\"value\"))\n                .unwrap_or_else(|| toml::Value::String(value.to_string()));\n            entries.push((key.to_string(), value, \"--tool-option\"));\n        }\n        let mut seen = std::collections::HashSet::new();\n        for (key, value, flag) in entries {\n            if !seen.insert(key.clone()) {\n                bail!(\n                    \"tool option {key:?} was specified more than once for {}\",\n                    self.tool\n                );\n            }\n            if self\n                .tool\n                .ba\n                .explicit_opts()\n                .is_some_and(|options| options.contains_key(&key))\n            {\n                bail!(\n                    \"cannot combine {flag} with an inline {key} option for {}\",\n                    self.tool\n                );\n            }\n            options\n                .insert_option(key, value)\n                .map_err(|error| eyre!(error))?;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/use.rs#L192-L228","documentation":"Options accumulate across --tool-option and related flags into one set per tool. mise collects entries, deduplicates by key via a HashSet, and refuses when the same key appears more than once, since it cannot decide which value wins.","triggerScenarios":"`mise use node --tool-option a=1 --tool-option a=2`, or combining --tool-option and --raw-tool-option with the same key for the same tool in one invocation.","commonSituations":"Loops in scripts appending the same option repeatedly; merging flag lists from config/docs where the same key was set twice; overriding an option by repeating it, expecting last-wins semantics.","solutions":["Remove the duplicate occurrence and keep a single KEY=VALUE per key","If you need to override, pass only the new value once","Use a config file (mise.toml [tools] options) when several option values must coexist or be version-controlled"],"exampleFix":"// before\nmise use node --tool-option a=1 --tool-option a=2\n// after\nmise use node --tool-option a=2","handlingStrategy":"validation","validationCode":"const seen = new Set();\nfor (const o of toolOptions) {\n  const k = o.split('=')[0];\n  if (seen.has(k)) throw new Error(`duplicate tool option: ${k}`);\n  seen.add(k);\n}","typeGuard":"const hasDuplicateKeys = (opts: string[]) => {\n  const keys = opts.map(o => o.split('=')[0]);\n  return new Set(keys).size !== keys.length;\n};","tryCatchPattern":"try { exec(`mise use ${flags} ${tool}`); } catch (e) { if (String(e).includes('more than once')) console.error('dedupe --tool-option keys; pass only one value per key'); throw e; }","preventionTips":["Build option lists through a Map keyed by option name so later values overwrite earlier ones","Never append flags inside loops without dedup","Move frequently-overridden options into mise.toml instead of repeating CLI flags"],"tags":["cli","tool-options","duplicate"],"backgroundTag":"conflicting-config-options","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}