{"record":{"id":"65b4229ad1eea616","repo":"mislav/hub","slug":"can-t-load-git-remote","errorCode":null,"errorMessage":"Can't load git remote","messagePattern":"Can't load git remote","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"github/remote.go","lineNumber":39,"sourceCode":"\nfunc (remote *Remote) String() string {\n\treturn remote.Name\n}\n\nfunc (remote *Remote) Project() (*Project, error) {\n\tp, err := NewProjectFromURL(remote.URL)\n\tif _, ok := err.(*HostError); ok {\n\t\treturn NewProjectFromURL(remote.PushURL)\n\t}\n\treturn p, err\n}\n\nfunc Remotes() (remotes []Remote, err error) {\n\tre := regexp.MustCompile(`(.+)\\s+(.+)\\s+\\((push|fetch)\\)`)\n\n\trs, err := git.Remotes()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Can't load git remote\")\n\t\treturn\n\t}\n\n\t// build the remotes map\n\tremotesMap := make(map[string]map[string]string)\n\tfor _, r := range rs {\n\t\tif re.MatchString(r) {\n\t\t\tmatch := re.FindStringSubmatch(r)\n\t\t\tname := strings.TrimSpace(match[1])\n\t\t\turl := strings.TrimSpace(match[2])\n\t\t\turlType := strings.TrimSpace(match[3])\n\t\t\tutm, ok := remotesMap[name]\n\t\t\tif !ok {\n\t\t\t\tutm = make(map[string]string)\n\t\t\t\tremotesMap[name] = utm\n\t\t\t}\n\t\t\tutm[urlType] = url\n\t\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/github/remote.go#L21-L57","documentation":"Remotes() runs git.Remotes() (parsing `git remote -v` output). If the underlying git command fails — i.e. remotes cannot even be listed — the error is replaced with this opaque message, discarding the cause. Callers like loadRemotes propagate it, so any remote-based operation fails with it.","triggerScenarios":"Calling Remotes() (directly or via loadRemotes → RemoteByName/RemoteForRepo/MainRemote/etc., or from RemoteBranchAndProject) when the `git remote -v` subprocess errors: not in a git repo, git not installed/on PATH, or corrupted .git/config.","commonSituations":"git binary missing in CI containers or PATH; running outside a repository; permission problems reading .git/config; broken git installation; sandboxed environments blocking process execution.","solutions":["Verify git works: run `git remote -v` manually and check for errors","Ensure the process runs inside a git repository working tree","Ensure git is installed and on PATH (which git); install or fix PATH in CI","Inspect .git/config for corruption and restore it (re-clone if needed)"],"exampleFix":"// before (CI image without git)\nremotes, err := github.Remotes() // Can't load git remote\n// after (Dockerfile)\nRUN apt-get update && apt-get install -y git\nremotes, err := github.Remotes() // works","handlingStrategy":"try-catch","validationCode":"if _, err := exec.LookPath(\"git\"); err != nil {\n    // git is not installed/on PATH; Remotes() will fail\n}","typeGuard":null,"tryCatchPattern":"remotes, err := github.Remotes()\nif err != nil {\n    if strings.Contains(err.Error(), \"Can't load git remote\") {\n        return fmt.Errorf(\"cannot list remotes; ensure git is installed and cwd is a repo: %w\", err)\n    }\n    return err\n}","preventionTips":["Install git and confirm `which git` succeeds in the runtime environment","Run inside a git repository working tree","In containers, include git in the image and preserve PATH","Sanity-check `git remote -v` runs without error before library calls"],"tags":["git","subprocess","environment"],"backgroundTag":"git-command-failed","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}