coleam00/Archon · error
Failed to clone repository: ${safeErr.message}
Error message
Failed to clone repository: ${safeErr.message} What it means
cloneRepository runs `git clone` with GIT_TERMINAL_PROMPT=0 so credential prompts fail fast instead of hanging. Any git clone failure is sanitized (credentials stripped) and rethrown as 'Failed to clone repository: <reason>'.
Source
Thrown at packages/core/src/handlers/clone.ts:393
// Remove the empty source/ directory before cloning (git clone requires non-existent target)
try {
await rm(targetPath, { recursive: true });
} catch (error) {
const err = error as NodeJS.ErrnoException;
if (err.code !== 'ENOENT') {
throw error;
}
}
try {
// GIT_TERMINAL_PROMPT=0 turns any missing-creds scenario into an
// immediate, readable error instead of a hung stdin credential prompt.
await execFileAsync('git', ['clone', cloneUrl, targetPath], {
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
});
} catch (error) {
const safeErr = sanitizeError(error as Error);
throw new Error(`Failed to clone repository: ${safeErr.message}`);
}
// Add to git safe.directory
await execFileAsync('git', ['config', '--global', '--add', 'safe.directory', targetPath]);
getLog().debug({ path: targetPath }, 'safe_directory_added');
const result = await registerRepoAtPath(targetPath, `${ownerName}/${repoName}`, workingUrl);
getLog().info({ url: workingUrl, targetPath }, 'clone_completed');
return result;
}
/**
* Register an existing local repository in the database (no git clone).
*/
export async function registerRepository(localPath: string): Promise<RegisterResult> {
// Validate path exists and is a git repo
try {
await execFileAsync('git', ['-C', localPath, 'rev-parse', '--git-dir']);View on GitHub (pinned to 0773b97458)
Solutions
- Run `git clone <url>` manually to see the underlying git error
- For private repos, configure credentials: `gh auth login` or a credential helper / deploy key
- Verify the clone URL and that the repo exists and you have access
- Check network/proxy connectivity to github.com; switch SSH URL to HTTPS if SSH keys are missing
Example fix
// before
await cloneRepository({ url: 'git@github.com:acme/private.git' });
// after
// gh auth login (or use HTTPS URL with token)
await cloneRepository({ url: 'https://github.com/acme/private.git' }); Defensive patterns
Strategy: try-catch
Validate before calling
await new Promise((res, rej) => execFile('git', ['ls-remote', cloneUrl], (e) => e ? rej(e) : res(null))); Try / catch
try { await cloneRepository(args); } catch (e) { if (e.message.startsWith('Failed to clone repository')) { console.error(e.message + '\nCheck: URL correctness, credentials (gh auth login), and network access.'); } throw e; } Prevention
- Authenticate before cloning private repos (gh auth login or credential helper)
- Pre-verify repo access with `git ls-remote <url>`
- Use HTTPS URLs unless SSH keys are configured for the runtime user
- Ensure network/proxy allows github.com from the execution environment
When it happens
Trigger: Calling cloneRepository when `git clone <cloneUrl> <targetPath>` exits non-zero: bad URL, nonexistent repo, missing/invalid credentials for a private repo, network failure, or existing non-empty target.
Common situations: Private repo without a configured credential helper or token; typo'd clone URL; no network access / proxy blocking github.com; SSH key not set up while using an SSH URL; repo deleted or renamed.
Related errors
- Failed to clone ${owner}/${repo}: ${'message' in cloneResult
- Failed to clone ${owner}/${repo}: ${unknownMsg}
- Authentication failed for ${owner}/${repo}. ${authHint}
- user_fetch_failed
- Directory already exists: ${targetPath} No matching codebas
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/128caca0bbb19a0a.
Report an issue: GitHub.