{"record":{"id":"517e71432fda3577","repo":"astrid-runtime/astrid","slug":"failed-to-clone-repository-from-github","errorCode":null,"errorMessage":"Failed to clone repository from GitHub.","messagePattern":"Failed to clone repository from GitHub\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install.rs","lineNumber":574,"sourceCode":"\n/// Clone a GitHub repository and build the capsule from source using\n/// `astrid-build`. Returns the installed capsule id.\nasync fn clone_and_build(\n    url: &str,\n    repo: &str,\n    name_hint: Option<&str>,\n    context: InstallContext<'_>,\n) -> anyhow::Result<InstalledCapsuleOutcome> {\n    let tmp_dir = tempfile::tempdir().context(\"failed to create temp dir for cloning\")?;\n    let clone_dir = tmp_dir.path().join(repo);\n\n    let status = std::process::Command::new(\"git\")\n        .args([\"clone\", \"--depth\", \"1\", url, &clone_dir.to_string_lossy()])\n        .status()\n        .context(\"Failed to spawn git clone\")?;\n\n    if !status.success() {\n        bail!(\"Failed to clone repository from GitHub.\");\n    }\n\n    let output_dir = tmp_dir.path().join(\"dist\");\n    std::fs::create_dir_all(&output_dir)?;\n\n    let build_bin = crate::bootstrap::find_companion_binary(\"astrid-build\")?;\n    let build_status = std::process::Command::new(build_bin)\n        .arg(clone_dir.to_str().context(\"Invalid clone dir path\")?)\n        .arg(\"--output\")\n        .arg(output_dir.to_str().context(\"Invalid output dir path\")?)\n        .status()\n        .context(\"Failed to run astrid-build\")?;\n    if !build_status.success() {\n        bail!(\n            \"astrid-build failed with exit code {}\",\n            build_status.code().unwrap_or(1)\n        );\n    }","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install.rs#L556-L592","documentation":"`clone_and_build` shells out to `git clone --depth 1 <url>` into a temp directory and bails with this message when the clone subprocess reports non-zero exit status. The error is generic by design — git's own diagnostics are printed to stderr by the child process, and this message just signals that the clone step of source-based capsule installation failed.","triggerScenarios":"Installing a capsule from a GitHub source URL when `git clone` exits non-zero: the repository does not exist or is private, no network access, bad URL, git not handling credentials for a private repo, or the local clone directory already exists.","commonSituations":"Typo in the org/repo URL; attempting to install a private capsule repo without GitHub credentials configured (no SSH key / no gh auth); corporate proxy or offline environment blocking github.com; repo renamed or deleted.","solutions":["Run the same `git clone --depth 1 <url>` manually to see git's actual error message","Verify the repo URL exists and is spelled correctly (org/repo) on github.com","If the repo is private, configure credentials: `gh auth login` or set up SSH keys / a credential helper so git can authenticate","Check network connectivity / proxy settings (HTTPS_PROXY, corporate firewall) that may block github.com","Ensure the temp clone directory does not already exist or is writable"],"exampleFix":"// before: private repo, no credentials → clone fails\nastrid capsule install github:myorg/private-capsule\n// after: authenticate git first\ngh auth login\nastrid capsule install github:myorg/private-capsule","handlingStrategy":"try-catch","validationCode":"// Verify reachability and credentials before install\nlet url = format!(\"https://github.com/{org}/{repo}\");\nlet ok = std::process::Command::new(\"git\")\n    .args([\"ls-remote\", &url])\n    .status()\n    .map(|s| s.success())\n    .unwrap_or(false);\nif !ok { eprintln!(\"cannot access {url}: check repo exists and git auth is configured\"); }","typeGuard":null,"tryCatchPattern":"match clone_and_build(url, ...) {\n    Ok(id) => proceed(id),\n    Err(e) if e.to_string().contains(\"Failed to clone repository\") => {\n        // git's real error was on stderr: advise running\n        // `git clone --depth 1 {url}` manually to see it\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Test `git ls-remote https://github.com/org/repo` before scripted installs to catch auth/network issues early","Run `gh auth login` or configure SSH keys when installing from private repos","Check git is installed and on PATH (`git --version`) in CI or container environments","Validate the org/repo URL in config to avoid typos and renamed repositories"],"tags":["git","clone","github","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}