jdx/mise · error

repository operation failed ({})

Error message

repository operation failed ({})

What it means

remote_repository drives a local git repository (for remote-host onboarding state) by shelling out to `git -C <path> <args>`. When a synchronous git invocation exits non-zero, mise wraps nothing from stderr and instead raises this generic error containing only the exit status.

Source

Thrown at src/system/remote_repository.rs:21

use std::{
    path::{Path, PathBuf},
    process::Command,
};

#[derive(Debug)]
pub(crate) struct Source {
    _directory: tempfile::TempDir,
    pub bundle: PathBuf,
    pub revision: String,
    pub origin: String,
}

fn git(path: &Path, args: &[&str]) -> Result<String> {
    let mut command = Command::new("git");
    crate::git::sanitize_git_command(&mut command);
    let output = command.arg("-C").arg(path).args(args).output()?;
    if !output.status.success() {
        bail!("repository operation failed ({})", output.status);
    }
    Ok(String::from_utf8(output.stdout)?
        .trim_end_matches('\n')
        .to_string())
}

async fn git_async(path: &Path, args: &[&str]) -> Result<String> {
    let mut command = Command::new("git");
    crate::git::sanitize_git_command(&mut command);
    command.arg("-C").arg(path).args(args);
    let output = tokio::process::Command::from(command)
        .kill_on_drop(true)
        .output()
        .await?;
    if !output.status.success() {
        bail!("repository operation failed ({})", output.status);
    }
    Ok(String::from_utf8(output.stdout)?

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Re-run the failing operation with the underlying git command manually in the repo path to see the real stderr
  2. Remove stale lock files (e.g. .git/index.lock) if a previous git process crashed
  3. Re-create the repository state (delete and let mise reinstall/reinit) if it is corrupted

Example fix

// before (stale lock)
rm: leave .git/index.lock in place
// after
rm .git/index.lock && retry the mise remote operation
Defensive patterns

Strategy: retry

Validate before calling

const repoHealthy = (dir) => execFileSync('git', ['-C', dir, 'status', '--porcelain'], { stdio: 'ignore' }); // throws if repo is broken

Try / catch

try { git(dir, args); } catch (e) { if (isIndexLockError(dir)) { rmIndexLock(dir); return retry(git, dir, args); } throw e; }

Prevention

When it happens

Trigger: Any git subcommand run by history_branch, install_at, repository, commit, etc. fails: not a git repository, bad ref/branch name, index lock present, merge conflicts, unreadable repo, git not on PATH (that would be an io error though — this fires specifically on non-zero exit).

Common situations: Corrupted or locked repo (.git/index.lock left over); detached/missing branch; conflicting changes during adoption; running in a sandbox without git credentials for an authenticated remote.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/ec2d4d381d91f4af. Report an issue: GitHub.