{"record":{"id":"b84ca6b3dafb2d5d","repo":"jdx/mise","slug":"failed-to-split-activation-flags","errorCode":null,"errorMessage":"failed to split activation flags","messagePattern":"failed to split activation flags","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shell/bash.rs","lineNumber":25,"sourceCode":"use crate::env;\nuse crate::shell::{self, ActivateOptions, Shell};\n\n#[derive(Default)]\npub(super) struct Bash {}\n\nimpl Bash {}\n\nfn render_template(template: &str, replacements: &[(&str, &str)]) -> String {\n    let mut out = template.to_owned();\n    for (needle, value) in replacements {\n        out = out.replace(needle, value);\n    }\n    out\n}\n\nfn render_flags_array(value: &str) -> String {\n    shell_words::split(value)\n        .expect(\"failed to split activation flags\")\n        .into_iter()\n        .map(|word| escape(word.into()).to_string())\n        .collect::<Vec<_>>()\n        .join(\" \")\n}\n\nimpl Shell for Bash {\n    fn activate(&self, opts: ActivateOptions) -> String {\n        let exe = opts.exe;\n        let settings = Settings::get();\n\n        let exe = exe.to_string_lossy();\n        let exe = escape(crate::windows_posix::executable_for_shell(&exe));\n        let flags = render_flags_array(&opts.flags);\n\n        let mut out = String::new();\n\n        out.push_str(&shell::build_deactivation_script(self));","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/shell/bash.rs#L7-L43","documentation":"render_flags_array splits the configured activation flags string with shell_words::split and unwraps with expect, panicking if the string contains unbalanced quotes or an unterminated escape. shell_words follows POSIX shell tokenization, so malformed quoting makes the value unsplittable.","triggerScenarios":"A user sets mise's activation flags setting (e.g. in settings or config) to a string with unbalanced quotes, a lone backslash, or otherwise invalid shell syntax; the activate command for bash then panics in render_flags_array.","commonSituations":"Copy-pasting flags with smart quotes or missing closing quote; setting flags like --no-init-files \" without the closing quote; environment-variable interpolation introducing stray characters.","solutions":["Fix the activation flags value so it is valid POSIX shell syntax (balanced quotes, complete escapes)","Unset the flags option to fall back to defaults","Test the string with `sh -c 'for f in <your flags>; do echo $f; done'` before saving it"],"exampleFix":"// before\nMISE_ACTIVATE_FLAGS=\"--no-rc 'unterminated\"\n// after\nMISE_ACTIVATE_FLAGS=\"--no-rc --noprofile\"","handlingStrategy":"validation","validationCode":"// validate flags before configuring\nif shlex::split(flags).is_none() {\n    eprintln!(\"invalid activation flags: unbalanced quotes\");\n}","typeGuard":null,"tryCatchPattern":"match shell_words::split(value) {\n    Ok(words) => words,\n    Err(e) => { eprintln!(\"bad activation flags: {e}\"); Default::default() }\n}","preventionTips":["Quote flag values with plain ASCII quotes","Validate shell syntax of config strings before saving","Test activation output in a fresh shell after changing flags"],"tags":["shell","bash","config","panic","quoting"],"backgroundTag":"invalid-argument-format","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"}