{"record":{"id":"c448e4cbd0c57eec","repo":"jdx/mise","slug":"mise-cannot-derive-completions-from-a-format-spe","errorCode":null,"errorMessage":"mise cannot derive completions from a {format} spec","messagePattern":"mise cannot derive completions from a (.+?) spec","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/packslip.rs","lineNumber":1403,"sourceCode":"        .envs(env)\n        .prepend_path(vec![install_path.join(MISE_BINS_DIR)])?\n        .current_dir(work.path())\n        .stdin(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .with_timeout(timeout)\n        .read_isolated(4 * 1024 * 1024)\n        .await?;\n    if output.trim().is_empty() {\n        bail!(\"resource command produced no output\");\n    }\n    Ok(output)\n}\n\n/// Derive a completion script from a CLI spec with the consumer's own\n/// tooling. Only the `usage` format is known.\nfn derive_from_spec(format: &str, bin: &str, spec: &Path, shell: &str) -> Result<String> {\n    if format != \"usage\" {\n        bail!(\"mise cannot derive completions from a {format} spec\");\n    }\n    // Validate before returning a loader, so an invalid preferred spec still\n    // falls through to another resource source.\n    file::read_to_string(spec)?\n        .parse::<usage::Spec>()\n        .map_err(|err| eyre!(\"invalid usage specification: {err}\"))?;\n    let shell = usage_rs::complete::Shell::from_name(shell)\n        .ok_or_else(|| eyre!(\"unsupported completion shell: {shell}\"))?;\n    let path = completions::encode_spec_path(spec);\n    let script = usage_rs::script::script_for(\"mise\", bin, shell);\n    Ok(script.replace(\n        \" __complete_word__ \",\n        &format!(\" __usage_complete_word {path} \"),\n    ))\n}\n\n/// The `shell` completion script for `tool`, from the packslip of the\n/// version that is active right now.","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/packslip.rs#L1385-L1421","documentation":"derive_from_spec generates a completion script from a CLI spec file using the tool's own usage tooling. Only the `usage` format is supported; any other declared format (e.g. clap_complete, shtool) bails with this error so the caller can fall back to another resource source.","triggerScenarios":"A packslip completion resource declares a spec with format set to something other than \"usage\" and mise tries to derive completions from that spec file.","commonSituations":"Packslip written for a tool that emits a different spec format, copy-pasted format field from another tool, upstream switched spec format.","solutions":["Set the spec format to \"usage\" if the tool emits a usage spec","Convert/produce a usage-format spec for the tool (e.g. via usage CLI)","Remove the spec-based completion resource and rely on an exec-based one instead","Validate the spec parses (an invalid usage spec also fails after this check)"],"exampleFix":"// before (packslip)\n// format = \"clap_complete\"\n// after\n// format = \"usage\"","handlingStrategy":"fallback","validationCode":"if (format !== 'usage') console.warn(`format ${format} unsupported; will fall back`);","typeGuard":null,"tryCatchPattern":"try { script = await deriveFromSpec(format, bin, spec, shell) } catch (e) { if (/cannot derive completions from a .* spec/.test(e.message)) { script = await execBasedCompletion(); } else { throw e; } }","preventionTips":["Declare spec format 'usage' only when the tool emits usage specs","Keep a fallback exec-based completion entry in the packslip","Validate the spec parses with the usage CLI","Track upstream spec-format changes"],"tags":["packslip","completion","usage-spec","unsupported-format"],"backgroundTag":"unsupported-operation","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"}