mislav/hub · error
Can't load git remote
Error message
Can't load git remote
What it means
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.
Source
Thrown at github/remote.go:39
func (remote *Remote) String() string {
return remote.Name
}
func (remote *Remote) Project() (*Project, error) {
p, err := NewProjectFromURL(remote.URL)
if _, ok := err.(*HostError); ok {
return NewProjectFromURL(remote.PushURL)
}
return p, err
}
func Remotes() (remotes []Remote, err error) {
re := regexp.MustCompile(`(.+)\s+(.+)\s+\((push|fetch)\)`)
rs, err := git.Remotes()
if err != nil {
err = fmt.Errorf("Can't load git remote")
return
}
// build the remotes map
remotesMap := make(map[string]map[string]string)
for _, r := range rs {
if re.MatchString(r) {
match := re.FindStringSubmatch(r)
name := strings.TrimSpace(match[1])
url := strings.TrimSpace(match[2])
urlType := strings.TrimSpace(match[3])
utm, ok := remotesMap[name]
if !ok {
utm = make(map[string]string)
remotesMap[name] = utm
}
utm[urlType] = url
}View on GitHub (pinned to 5c547ed804)
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)
Example fix
// before (CI image without git) remotes, err := github.Remotes() // Can't load git remote // after (Dockerfile) RUN apt-get update && apt-get install -y git remotes, err := github.Remotes() // works
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := exec.LookPath("git"); err != nil {
// git is not installed/on PATH; Remotes() will fail
} Try / catch
remotes, err := github.Remotes()
if err != nil {
if strings.Contains(err.Error(), "Can't load git remote") {
return fmt.Errorf("cannot list remotes; ensure git is installed and cwd is a repo: %w", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- 'create' must be run from inside a git repository
- error running git version: %s
- Not a git repository (or any of the parent directories): .gi
- Can't load git var: GIT_EDITOR
- Please set $BROWSER to a web launcher
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/65b4229ad1eea616.
Report an issue: GitHub.