yamadashy/repomix · error · RepomixError
Failed to clone repository: ${redactErrorMessage(error)}
Error message
Failed to clone repository: ${redactErrorMessage(error)} What it means
Repomix wraps any failure from the shallow git clone of a remote repository (used by `repomix --remote`) into a single RepomixError with a redacted error message. The thrown error could be an invalid URL, network failure, nonexistent repository/branch, or missing git binary; the library hides the raw stderr behind `redactErrorMessage` to avoid leaking credentials embedded in URLs.
Source
Thrown at src/cli/actions/remoteAction.ts:275
logger.trace(`Created temporary directory. (path: ${pc.dim(tempDir)})`);
return tempDir;
};
export const cloneRepository = async (
url: string,
directory: string,
remoteBranch?: string,
deps = {
execGitShallowClone,
},
): Promise<void> => {
logger.log(`Clone repository: ${redactUrl(url)} to temporary directory. ${pc.dim(`path: ${directory}`)}`);
logger.log('');
try {
await deps.execGitShallowClone(url, directory, remoteBranch);
} catch (error) {
throw new RepomixError(`Failed to clone repository: ${redactErrorMessage(error)}`);
}
};
export const cleanupTempDirectory = async (directory: string): Promise<void> => {
logger.trace(`Cleaning up temporary directory: ${directory}`);
await fs.rm(directory, { recursive: true, force: true });
};
export const copyOutputToCurrentDirectory = async (
sourceDir: string,
targetDir: string,
outputFileName: string,
): Promise<void> => {
const sourcePath = path.resolve(sourceDir, outputFileName);
const targetPath = path.resolve(targetDir, outputFileName);
// Skip copy if source and target are the same
// This can happen when an absolute path is specified for the output fileView on GitHub (pinned to f465ad9093)
Solutions
- Verify the repository URL is correct and reachable: `git ls-remote <url>`
- If the repo is private, ensure credentials work (SSH keys or HTTPS token) for the user running repomix
- Confirm git is installed and on PATH (`git --version`)
- If using `--remote-branch`, check the branch exists in the remote
- Check network/proxy connectivity to the git host
Example fix
// before
await repomixRemote('https://github.com/owner/no-such-repo');
// after
const url = 'https://github.com/owner/real-repo';
await exec(`git ls-remote ${url}`); // validate first
await repomixRemote(url); Defensive patterns
Strategy: try-catch
Validate before calling
const { code } = spawnSync('git', ['ls-remote', url], { encoding: 'utf8' });
if (code !== 0) throw new Error(`Repository unreachable: ${url}`); Type guard
const isErrnoException = (e: unknown): e is NodeJS.ErrnoException =>
e instanceof Error && ('code' in e); Try / catch
try {
await runRepomix({ remote: url });
} catch (e) {
if (e instanceof RepomixError && e.message.startsWith('Failed to clone repository')) {
console.error('Check URL, credentials, network, and that git is installed.');
}
throw e;
} Prevention
- Validate the repo URL with `git ls-remote` before invoking repomix
- Keep git installed and credentials (SSH keys/tokens) configured
- Test branch names with `git ls-remote --heads` before `--remote-branch`
When it happens
Trigger: Calling `runRemoteAction`/`cloneRepository` (or `repomix --remote <url>`) where `deps.execGitShallowClone(url, directory, remoteBranch)` rejects: unreachable host, bad URL, auth required on a private repo, nonexistent branch passed via `--remote-branch`, or git not installed.
Common situations: Typing a wrong repo URL (typo in owner/name), cloning a private repo without SSH keys/credentials configured, offline or proxied networks blocking github.com, specifying a branch that doesn't exist, or corporate environments without git on PATH.
Related errors
- Failed to get remote refs: ${redactErrorMessage(error)}
- Git is not installed or not in the system PATH.
- Invalid repository URL. URL contains potentially dangerous p
- Invalid URL protocol for '${redactUrl(url)}'. URL must start
- Invalid repository URL. Please provide a valid URL: ${redact
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/6f1acf2bc431e4c8.
Report an issue: GitHub.