jdx/mise · error

edits: " ": , fix the file manually

Error message

edits: "{}": {reason}, fix the file manually

What it means

Thrown in `unapply_one` (invoked from execute_unapply) when removing a Block edit: `find_block` fails to locate a well-formed managed block in the file (e.g. opening marker without a closing marker, mismatched id, or nested/mangled markers). Because removing half of a broken block could destroy user content, the operation refuses and asks the user to fix the file manually.

Solutions

  1. Open the file named in the error and repair the managed block markers so they are balanced and carry the expected id.
  2. If the block content is no longer wanted, delete the whole block (markers and body) manually.
  3. Re-run the unapply; a correctly removed block will make find_block return None and unapply proceeds.
  4. If markers changed style (e.g. different comment syntax), restore the exact original style the tool wrote.

Example fix

// before: dangling marker (no close)
# >>> managed block id=exports
export FOO=1
// after: delete entire block or add closing marker
# >>> managed block id=exports
export FOO=1
# <<< managed block id=exports
Defensive patterns

Strategy: validation

Validate before calling

fn block_markers_balanced(text: &str, id: &str) -> bool {
    let open = format!(">>> managed block id={}", id);
    let close = format!("<<< managed block id={}", id);
    text.matches(&open).count() == 1 && text.matches(&close).count() == 1
}

Try / catch

match result {
    Err(e) if e.to_string().contains("fix the file manually") => {
        // open the named file, repair/remove the broken block, then retry
    }
    other => other?,
}

Prevention

When it happens

Trigger: Unapplying an `EditOp::Block` entry whose comment markers in the target file are missing, malformed, unbalanced, or belong to a different block id — find_block returns Err(reason) instead of Ok(Some(range)) or Ok(None).

Common situations: User manually deleted the closing marker of a managed block; a formatter reflowed comment markers; block ids were renamed in the config so the file's markers no longer match; partial application was interrupted leaving a half-written block.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/78cefdc699fcbc90. Report an issue: GitHub.

Appendix: source

Thrown at src/system/edits.rs:1050

        "edits: unapplied {}",
        todo.iter()
            .map(|plan| format!("{} ({})", plan.req.path_raw, plan.req.describe_op()))
            .collect::<Vec<_>>()
            .join(", ")
    );
    Ok(())
}

fn unapply_one(req: &EditRequest) -> Result<()> {
    let text = file::read_to_string(&req.path)?;
    let lines = text_lines(&text);
    let remove = match &req.op {
        EditOp::Block { comment, .. } => {
            let refs = lines.iter().map(|line| line.content).collect::<Vec<_>>();
            match find_block(&refs, &req.id, comment) {
                Ok(Some((begin, end))) => lines[begin].start..lines[end].end,
                Ok(None) => return Ok(()),
                Err(reason) => bail!(
                    "edits: \"{}\": {reason}, fix the file manually",
                    req.path_raw
                ),
            }
        }
        EditOp::Line { line, position } => {
            // Use the occurrence nearest the configured insertion edge as the
            // best stateless approximation of the line mise added.
            let found = match position {
                LinePosition::Prepend => lines.iter().find(|candidate| candidate.content == line),
                LinePosition::Append => lines.iter().rfind(|candidate| candidate.content == line),
            };
            if let Some(found) = found {
                found.start..found.end
            } else {
                return Ok(());
            }
        }

View on GitHub (pinned to 533346cc37)