{"record":{"id":"93297d497b6a22ae","repo":"golang/go","slug":"not-a-known-dependency","errorCode":null,"errorMessage":"not a known dependency","messagePattern":"not a known dependency","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/modload/list.go","lineNumber":279,"sourceCode":"\t\t\tif v != \"none\" {\n\t\t\t\tmods = append(mods, moduleInfo(ld, ctx, rs, module.Version{Path: arg, Version: v}, mode, reuse))\n\t\t\t} else if cfg.BuildMod == \"vendor\" {\n\t\t\t\t// In vendor mode, we can't determine whether a missing module is “a\n\t\t\t\t// known dependency” because the module graph is incomplete.\n\t\t\t\t// Give a more explicit error message.\n\t\t\t\tmods = append(mods, &modinfo.ModulePublic{\n\t\t\t\t\tPath:  arg,\n\t\t\t\t\tError: modinfoError(arg, \"\", errors.New(\"can't resolve module using the vendor directory\\n\\t(Use -mod=mod or -mod=readonly to bypass.)\")),\n\t\t\t\t})\n\t\t\t} else if mode&ListVersions != 0 {\n\t\t\t\t// Don't make the user provide an explicit '@latest' when they're\n\t\t\t\t// explicitly asking what the available versions are. Instead, return a\n\t\t\t\t// module with version \"none\", to which we can add the requested list.\n\t\t\t\tmods = append(mods, &modinfo.ModulePublic{Path: arg})\n\t\t\t} else {\n\t\t\t\tmods = append(mods, &modinfo.ModulePublic{\n\t\t\t\t\tPath:  arg,\n\t\t\t\t\tError: modinfoError(arg, \"\", errors.New(\"not a known dependency\")),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tvar matches []module.Version\n\t\tfor _, m := range mg.BuildList() {\n\t\t\tif match(m.Path) {\n\t\t\t\tif !matchedModule[m] {\n\t\t\t\t\tmatchedModule[m] = true\n\t\t\t\t\tmatches = append(matches, m)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif len(matches) == 0 {\n\t\t\tfmt.Fprintf(os.Stderr, \"warning: pattern %q matched no module dependencies\\n\", arg)\n\t\t}","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/list.go#L261-L297","documentation":"When listing modules in non-vendor mode and a path resolves to version \"none\" (not in the build list), and the user is not asking for the list of available versions, the go command marks the module with this Error rather than silently omitting it. It means: nothing in the current module graph matches that path.","triggerScenarios":"`go list -m <path>` with no @version, where <path> is not a dependency of the main module and BuildMod is not vendor.","commonSituations":"Typos in the path; querying a transitive dependency that isn't selected; checking if something is required before adding it.","solutions":["Add the dependency: `go get <path>`.","Query with an explicit version: `go list -m <path>@latest`.","Check the path for typos against go.mod."],"exampleFix":"# before\n$ go list -m exampple.com/foo   # typo\n# Error: not a known dependency\n\n# after\n$ go list -m example.com/foo@latest","handlingStrategy":"validation","validationCode":"// Confirm a module is a known dependency before listing it.\nfunc isKnownDep(modPath string) bool {\n    b, err := os.ReadFile(\"go.mod\")\n    if err != nil { return false }\n    return bytes.Contains(b, []byte(modPath))\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use `<path>@version` when querying modules not yet in the graph.","Run `go get <path>` before listing it.","Check go.mod for typos in paths."],"tags":["module-resolution","go-list","dependencies"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}