{"record":{"id":"c38f3f30e83a034c","repo":"jdx/mise","slug":"config-set-requires-a-toml-config-file-but-is","errorCode":null,"errorMessage":"config set requires a TOML config file, but {} is not TOML","messagePattern":"config set requires a TOML config file, but (.+?) is not TOML","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config/set.rs","lineNumber":124,"sourceCode":"        let file = match self.file {\n            Some(path) => Some(resolve_target_config_path(ConfigPathOptions {\n                path: Some(path),\n                prefer_toml: true,\n                ..Default::default()\n            })?),\n            None if self.global => Some(resolve_target_config_path(ConfigPathOptions {\n                global: true,\n                prefer_toml: true,\n                ..Default::default()\n            })?),\n            None if self.system => Some(system_config_path()),\n            None => top_toml_config(),\n        };\n        let Some(file) = file else {\n            bail!(\"No mise.toml file found\");\n        };\n        if !file.to_string_lossy().ends_with(\".toml\") {\n            bail!(\n                \"config set requires a TOML config file, but {} is not TOML\",\n                display_path(&file)\n            );\n        }\n        if !file.exists() && !self.global && !self.system {\n            bail!(\"config file not found: {}\", display_path(&file));\n        }\n        let raw = match std::fs::read_to_string(&file) {\n            Ok(raw) => raw,\n            Err(error)\n                if (self.global || self.system) && error.kind() == std::io::ErrorKind::NotFound =>\n            {\n                String::new()\n            }\n            Err(error) => return Err(error.into()),\n        };\n        let mut config: toml_edit::DocumentMut = raw.parse()?;\n        let mut container = config.as_item_mut();","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/config/set.rs#L106-L142","documentation":"`mise config set` writes TOML values, so the resolved target file must have a `.toml` extension. If the selected file resolves but is not TOML (e.g. `.tool-versions`, `.mise.toml` is fine but other formats or non-toml paths aren't), mise bails rather than corrupting a non-TOML file with toml_edit writes.","triggerScenarios":"`mise config set ... --file <path>` (or another selection) where the path does not end in `.toml` — e.g. pointing at `.tool-versions`, an idiomatic-files config, or a YAML/JSON config path.","commonSituations":"Users try to edit `.tool-versions` via `mise config set --file`; scripts pass a config path variable that points at a legacy format file.","solutions":["Target a TOML file: use the default mise.toml or pass `--file /path/to/mise.toml`","Convert legacy `.tool-versions` to mise.toml (`mise config migrate` style tooling or copy entries into `[tools]`)","For non-TOML formats use the format-appropriate command (e.g. `mise use --file .tool-versions` semantics) or edit manually"],"exampleFix":"// before\n$ mise config set --file .tool-versions tools.node 20  # not TOML\n// after\n$ mise config set --global tools.node 20  # writes ~/.config/mise/config.toml","handlingStrategy":"validation","validationCode":"case \"$file\" in *.toml) ;; *) echo \"$file is not TOML\"; exit 1;; esac","typeGuard":"is_toml_path() { case \"$1\" in *.toml) return 0;; *) return 1;; esac; }","tryCatchPattern":"mise config set --file \"$f\" \"$k\" \"$v\" 2>&1 | grep -q 'not TOML' && { echo \"convert $f to mise.toml first\"; exit 1; }","preventionTips":["Only pass .toml paths to --file","Convert .tool-versions/legacy configs to mise.toml before programmatic edits","Use `mise use` for tool-version-only files","Validate file extensions in wrapper scripts"],"tags":["config","toml","cli","invalid-argument"],"backgroundTag":"invalid-config-value","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"}