{"record":{"id":"6478a3648ef63961","repo":"nikivdev/code","slug":"failed-to-create-repo-via-gh-is-it-installed-auth","errorCode":null,"errorMessage":"failed to create repo via gh (is it installed/authenticated?)","messagePattern":"failed to create repo via gh \\(is it installed/authenticated\\?\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/push.rs","lineNumber":303,"sourceCode":"        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .status();\n\n    if matches!(view, Ok(s) if s.success()) {\n        return Ok(());\n    }\n\n    println!(\"==> Creating GitHub repo {} (private)...\", full_name);\n    let status = Command::new(\"gh\")\n        .args([\"repo\", \"create\", &full_name, \"--private\", \"--confirm\"])\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status();\n\n    match status {\n        Ok(s) if s.success() => Ok(()),\n        Ok(_) => bail!(\"failed to create repo via gh (is it installed/authenticated?)\"),\n        Err(err) => Err(err).context(\"failed to run gh\"),\n    }\n}\n\npub(crate) fn normalize_git_url(url: &str) -> String {\n    let url = url.trim();\n    let url = if url.starts_with(\"git@github.com:\") {\n        url.replace(\"git@github.com:\", \"github.com/\")\n    } else if url.starts_with(\"https://github.com/\") {\n        url.replace(\"https://github.com/\", \"github.com/\")\n    } else {\n        url.to_string()\n    };\n    url.trim_end_matches(\".git\").to_lowercase()\n}\n\nfn git_root() -> Result<PathBuf> {\n    let output = Command::new(\"git\")","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/push.rs#L285-L321","documentation":"Raised by ensure_github_repo_exists in src/push.rs when the `gh repo create <owner>/<repo> --private` subprocess exits non-zero (the `gh repo view` pre-check already showed the repo does not exist or is not visible). It indicates the GitHub CLI failed to create the mirror repository, most often because gh is not installed, not authenticated, or lacks permission.","triggerScenarios":"The `gh repo view owner/repo` check fails (repo absent or gh unauthenticated), then `gh repo create owner/repo --private --confirm` runs and returns a non-zero exit status.","commonSituations":"gh CLI not installed or not on PATH for the spawned process; `gh auth login` never run or token expired; the authenticated account lacks rights to create repos in the target owner (org); gh version where `--confirm` was removed/deprecated causing argument errors.","solutions":["Install the GitHub CLI and authenticate with `gh auth login`, then verify with `gh auth status`","Run `gh repo create owner/repo --private` manually to see the exact underlying error","Confirm you have permission to create repos under the target owner/org, or create the repo manually in GitHub and re-run the push"],"exampleFix":"// before: unauthenticated gh fails\n$ f push\nfailed to create repo via gh (is it installed/authenticated?)\n// after\n$ gh auth login\n$ f push","handlingStrategy":"validation","validationCode":"let ok = std::process::Command::new(\"gh\")\n    .args([\"auth\", \"status\"])\n    .status()\n    .map(|s| s.success())\n    .unwrap_or(false);\nif !ok { eprintln!(\"install gh and run `gh auth login` first\"); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"failed to create repo via gh\") => {\n        eprintln!(\"run `gh auth status` and `gh repo create` manually for details\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Install gh and run `gh auth login` before first push","Verify `gh repo view owner/repo` works beforehand","Ensure your account has repo-creation rights in the target org"],"tags":["github","gh-cli","auth"],"backgroundTag":"gh-cli-auth-missing","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}