{"record":{"id":"78cefdc699fcbc90","repo":"jdx/mise","slug":"edits-reason-fix-the-file-manually","errorCode":null,"errorMessage":"edits: \"{}\": {reason}, fix the file manually","messagePattern":"edits: \"(.+?)\": (.+?), fix the file manually","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/edits.rs","lineNumber":1050,"sourceCode":"        \"edits: unapplied {}\",\n        todo.iter()\n            .map(|plan| format!(\"{} ({})\", plan.req.path_raw, plan.req.describe_op()))\n            .collect::<Vec<_>>()\n            .join(\", \")\n    );\n    Ok(())\n}\n\nfn unapply_one(req: &EditRequest) -> Result<()> {\n    let text = file::read_to_string(&req.path)?;\n    let lines = text_lines(&text);\n    let remove = match &req.op {\n        EditOp::Block { comment, .. } => {\n            let refs = lines.iter().map(|line| line.content).collect::<Vec<_>>();\n            match find_block(&refs, &req.id, comment) {\n                Ok(Some((begin, end))) => lines[begin].start..lines[end].end,\n                Ok(None) => return Ok(()),\n                Err(reason) => bail!(\n                    \"edits: \\\"{}\\\": {reason}, fix the file manually\",\n                    req.path_raw\n                ),\n            }\n        }\n        EditOp::Line { line, position } => {\n            // Use the occurrence nearest the configured insertion edge as the\n            // best stateless approximation of the line mise added.\n            let found = match position {\n                LinePosition::Prepend => lines.iter().find(|candidate| candidate.content == line),\n                LinePosition::Append => lines.iter().rfind(|candidate| candidate.content == line),\n            };\n            if let Some(found) = found {\n                found.start..found.end\n            } else {\n                return Ok(());\n            }\n        }","sourceCodeStart":1032,"sourceCodeEnd":1068,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/edits.rs#L1032-L1068","documentation":"When physically removing a managed block from a file during unapply, unapply_one calls find_block to locate the exact begin/end lines for the request's id and comment style. If find_block returns an error reason (e.g. the markers are ambiguous, mismatched, or the target is a symlink case handled earlier), mise bails telling the user to fix the file manually rather than risk deleting the wrong lines.","triggerScenarios":"execute_unapply → unapply_one on an EditOp::Block request where find_block(&refs, &req.id, comment) returns Err(reason): the block markers in the file don't match what mise expects (wrong id, changed comment style/marker wording, nested or overlapping blocks).","commonSituations":"The user (or a formatter) edited the managed block, removed/altered the begin/end marker comments, or changed the comment style in config so the markers no longer match the file content; unapply then cannot locate the block.","solutions":["Open the file listed in the error and manually delete the managed block (from its begin marker to its end marker).","Alternatively re-run the corresponding `edits apply` so markers are rewritten to the current config, then unapply again.","Align the block's comment style/id in mise.toml with what is actually in the file, then unapply."],"exampleFix":"// before: file has stale/missing markers\n// some code\n\n// after: manually delete the managed block between markers\n// # mise:begin <id>\n// ...\n// # mise:end <id>\n// (removed) — or re-apply first: $ mise edits apply && mise edits unapply","handlingStrategy":"validation","validationCode":"# verify both markers exist for the block id before unapplying\ngrep -c 'mise:begin my-block' file && grep -c 'mise:end my-block' file","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never edit marker comment lines by hand","Re-apply edits after changing the block's comment style in config","Keep formatters from reflowing marker lines"],"tags":["rust","dotfiles","unapply","markers"],"backgroundTag":"resource-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}