{"record":{"id":"ec2d4d381d91f4af","repo":"jdx/mise","slug":"repository-operation-failed","errorCode":null,"errorMessage":"repository operation failed ({})","messagePattern":"repository operation failed \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote_repository.rs","lineNumber":21,"sourceCode":"use std::{\n    path::{Path, PathBuf},\n    process::Command,\n};\n\n#[derive(Debug)]\npub(crate) struct Source {\n    _directory: tempfile::TempDir,\n    pub bundle: PathBuf,\n    pub revision: String,\n    pub origin: String,\n}\n\nfn git(path: &Path, args: &[&str]) -> Result<String> {\n    let mut command = Command::new(\"git\");\n    crate::git::sanitize_git_command(&mut command);\n    let output = command.arg(\"-C\").arg(path).args(args).output()?;\n    if !output.status.success() {\n        bail!(\"repository operation failed ({})\", output.status);\n    }\n    Ok(String::from_utf8(output.stdout)?\n        .trim_end_matches('\\n')\n        .to_string())\n}\n\nasync fn git_async(path: &Path, args: &[&str]) -> Result<String> {\n    let mut command = Command::new(\"git\");\n    crate::git::sanitize_git_command(&mut command);\n    command.arg(\"-C\").arg(path).args(args);\n    let output = tokio::process::Command::from(command)\n        .kill_on_drop(true)\n        .output()\n        .await?;\n    if !output.status.success() {\n        bail!(\"repository operation failed ({})\", output.status);\n    }\n    Ok(String::from_utf8(output.stdout)?","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote_repository.rs#L3-L39","documentation":"The synchronous `git` helper in remote_repository runs a `git -C <path>` subprocess and, when git exits non-zero, wraps the exit status into this generic error. It means a git operation against the local mirror/repository backing remote mise state failed; the specific git stderr is not included, only the status code.","triggerScenarios":"Any git subcommand run by history_branch, install_at, repository, commit, or the adoption checks exits non-zero: corrupt/missing repository, unwritable directory, merge conflicts during adoption, bad refs, or git not behaving as expected.","commonSituations":"Repository directory deleted or corrupted mid-run; concurrent mise processes locking the repo; adopting an existing non-repo directory with conflicting files; disk-full or permission problems.","solutions":["Inspect the repository directory and run the failing git command manually to see the real stderr","Re-create/clean the repository state (delete the mirror and let mise re-initialize) if it is corrupt","Resolve file conflicts/locks from concurrent runs (remove stale .lock files, stop parallel mise invocations)","Check directory permissions and free disk space"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check before operations\nconst st = fs.statSync(repoPath);\nif (!st.isDirectory()) throw new Error('repository path missing');","typeGuard":null,"tryCatchPattern":"match git(path, args) {\n  Ok(out) => out,\n  Err(e) if e.to_string().starts_with(\"repository operation failed\") => {\n    // run the same git command manually to capture stderr, then recover\n    eprintln!(\"git {:?} failed: {e}; inspect repo at {:?}\", args, path);\n    recover_or_reinitialize(path)\n  }\n  Err(e) => return Err(e),\n}","preventionTips":["Check the repository directory exists and is writable before operations","Avoid running multiple mise processes against the same remote repo concurrently","Capture git stderr separately to make failures diagnosable","Re-create the repo if it becomes corrupt instead of fighting it"],"tags":["git","subprocess","repository"],"backgroundTag":"git-command-failed","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"}