{"record":{"id":"fb99224dd8201921","repo":"golang/go","slug":"git-remote-s-must-not-be-local-directory","errorCode":null,"errorMessage":"git remote (%s) must not be local directory","messagePattern":"git remote \\((.+?)\\) must not be local directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/git.go","lineNumber":71,"sourceCode":"\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}\n\t\treturn nil, fmt.Errorf(\"git remote (%s) must not be local directory\", remote)\n\t}\n\tvar err error\n\tr.dir, r.mu.Path, err = WorkDir(ctx, gitWorkDirType, r.remote)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tunlock, err := r.mu.Lock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer unlock()\n\n\tif _, err := os.Stat(filepath.Join(r.dir, \"objects\")); err != nil {\n\t\trepoSha256Hash := false\n\t\tif refs, lrErr := r.loadRefs(ctx); lrErr == nil {\n\t\t\t// Check any ref's hash, it doesn't matter which; they won't be mixed\n\t\t\t// between sha1 and sha256 for the moment.","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/git.go#L53-L89","documentation":"Thrown by newGitRepo in remote mode when the remote string has no '://' scheme AND no ':' — it looks like a bare path, not a URL. Go requires a proper URL scheme for remote git repos; a bare path is treated as a potential local directory, which is disallowed in remote mode.","triggerScenarios":"A module source string that is a relative or absolute filesystem path passed where a URL is expected, without a scheme. Happens with malformed replace directives or custom VCS tooling calling codehost directly.","commonSituations":"Replace directive using './path/to/repo' without 'file://' prefix when a remote is required; a module path that resolves to a bare path via a proxy misconfiguration; importing a local path as if it were a remote module.","solutions":["If the source is local, use local mode (replace with a filesystem path, which go handles natively).","If a remote URL is intended, add a scheme: 'file:///absolute/path' or 'https://host/repo.git'.","Check the replace directive and ensure it uses the correct form (path for local, URL for remote).","Run 'go mod edit -print' to inspect resolved paths."],"exampleFix":"// before (go.mod) — bare path in a context expecting a remote\nrequire example.com/mod v1.0.0 // resolves to bare path\n// after — use a proper replace for local\nreplace example.com/mod => /home/user/projects/mod","handlingStrategy":"validation","validationCode":"func validateRemoteURL(remote string) error {\n    if !strings.Contains(remote, \"://\") {\n        return fmt.Errorf(\"remote %q must be a URL with a scheme\", remote)\n    }\n    return nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use replace directives with filesystem paths for local sources.","For remote sources, always include a scheme (https://, ssh://, git://).","Validate go.mod after edits with 'go mod edit -print'."],"tags":["git","url","local-mode","replace-directive","config"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}