golang/go · error

git remote (%s) lookup disabled

Error message

git remote (%s) lookup disabled

What it means

Thrown by newGitRepo when called with local=true (meaning: treat the remote as a local filesystem path) but the remote string contains '://' — a URL scheme. Local mode and URL syntax are mutually exclusive; the tool refuses to interpret a URL as a local path.

Source

Thrown at src/cmd/go/internal/modfetch/codehost/git.go:52

	"golang.org/x/mod/semver"
)

// A notExistError wraps another error to retain its original text
// but makes it opaquely equivalent to fs.ErrNotExist.
type notExistError struct {
	err error
}

func (e notExistError) Error() string   { return e.err.Error() }
func (notExistError) Is(err error) bool { return err == fs.ErrNotExist }

const gitWorkDirType = "git3"

func newGitRepo(ctx context.Context, remote string, local bool) (Repo, error) {
	r := &gitRepo{remote: remote, local: local}
	if local {
		if strings.Contains(remote, "://") { // Local flag, but URL provided
			return nil, fmt.Errorf("git remote (%s) lookup disabled", remote)
		}
		info, err := os.Stat(remote)
		if err != nil {
			return nil, err
		}
		if !info.IsDir() {
			return nil, fmt.Errorf("%s exists but is not a directory", remote)
		}
		r.dir = remote
		r.mu.Path = r.dir + ".lock"
		r.sha256Hashes = r.checkConfigSHA256(ctx)
		return r, nil
	}
	// This is a remote path lookup.
	if !strings.Contains(remote, "://") { // No URL scheme, could be host:path
		if strings.Contains(remote, ":") {
			return nil, fmt.Errorf("git remote (%s) must not be local directory (use URL syntax not host:path syntax)", remote)
		}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Check go.mod replace directives: ensure local replacements point at filesystem paths, not URLs.
  2. Verify GOFLAGS does not contain flags forcing local mode.
  3. If calling codehost directly, pass local=false for URL remotes.
  4. Use 'file://' scheme consistently or a bare filesystem path.

Example fix

// before (go.mod)
replace example.com/mod => https://local.example.com/mod.git
// after
replace example.com/mod => ./internal/mod
// or call newGitRepo with local=false for URLs
Defensive patterns

Strategy: validation

Validate before calling

func validateRemoteString(remote string, local bool) error {
    hasScheme := strings.Contains(remote, "://")
    if local && hasScheme {
        return fmt.Errorf("local mode requested but remote %q is a URL", remote)
    }
    if !local && !hasScheme {
        return fmt.Errorf("remote mode requested but %q has no URL scheme", remote)
    }
    return nil
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: codehost.newGitRepo(ctx, remote, local=true) is invoked with a remote like 'https://example.com/repo.git'. Internally this happens when go's module resolution decides a source is local but the import string looks like a URL — typically a misconfigured GOFLAGS, replace directive, or vendoring setup.

Common situations: A replace directive pointing at a URL with -mod=vendor or a local-only mode; a custom VCS or proxy tool calling codehost internals with wrong flags; mixed local/remote module sources in go.mod.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/85bb52e242bac576. Report an issue: GitHub.