{"record":{"id":"85bb52e242bac576","repo":"golang/go","slug":"git-remote-s-lookup-disabled","errorCode":null,"errorMessage":"git remote (%s) lookup disabled","messagePattern":"git remote \\((.+?)\\) lookup disabled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/git.go","lineNumber":52,"sourceCode":"\t\"golang.org/x/mod/semver\"\n)\n\n// A notExistError wraps another error to retain its original text\n// but makes it opaquely equivalent to fs.ErrNotExist.\ntype notExistError struct {\n\terr error\n}\n\nfunc (e notExistError) Error() string   { return e.err.Error() }\nfunc (notExistError) Is(err error) bool { return err == fs.ErrNotExist }\n\nconst gitWorkDirType = \"git3\"\n\nfunc newGitRepo(ctx context.Context, remote string, local bool) (Repo, error) {\n\tr := &gitRepo{remote: remote, local: local}\n\tif local {\n\t\tif strings.Contains(remote, \"://\") { // Local flag, but URL provided\n\t\t\treturn nil, fmt.Errorf(\"git remote (%s) lookup disabled\", remote)\n\t\t}\n\t\tinfo, err := os.Stat(remote)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !info.IsDir() {\n\t\t\treturn nil, fmt.Errorf(\"%s exists but is not a directory\", remote)\n\t\t}\n\t\tr.dir = remote\n\t\tr.mu.Path = r.dir + \".lock\"\n\t\tr.sha256Hashes = r.checkConfigSHA256(ctx)\n\t\treturn r, nil\n\t}\n\t// This is a remote path lookup.\n\tif !strings.Contains(remote, \"://\") { // No URL scheme, could be host:path\n\t\tif strings.Contains(remote, \":\") {\n\t\t\treturn nil, fmt.Errorf(\"git remote (%s) must not be local directory (use URL syntax not host:path syntax)\", remote)\n\t\t}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/git.go#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check go.mod replace directives: ensure local replacements point at filesystem paths, not URLs.","Verify GOFLAGS does not contain flags forcing local mode.","If calling codehost directly, pass local=false for URL remotes.","Use 'file://' scheme consistently or a bare filesystem path."],"exampleFix":"// before (go.mod)\nreplace example.com/mod => https://local.example.com/mod.git\n// after\nreplace example.com/mod => ./internal/mod\n// or call newGitRepo with local=false for URLs","handlingStrategy":"validation","validationCode":"func validateRemoteString(remote string, local bool) error {\n    hasScheme := strings.Contains(remote, \"://\")\n    if local && hasScheme {\n        return fmt.Errorf(\"local mode requested but remote %q is a URL\", remote)\n    }\n    if !local && !hasScheme {\n        return fmt.Errorf(\"remote mode requested but %q has no URL scheme\", remote)\n    }\n    return nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Keep replace directives consistent: filesystem paths for local, URLs for remote.","Review go.mod after merges for misconfigured replace targets.","If calling codehost.newGitRepo directly, validate the local flag against the remote string first."],"tags":["git","local-mode","url","config","replace-directive"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}