{"record":{"id":"23103aa2fdb9bed5","repo":"apache/answer","slug":"failed-to-clone-s-s-w-tip-set-answer-module-t","errorCode":null,"errorMessage":"failed to clone %s@%s: %w\nTip: set ANSWER_MODULE to a local checkout path instead, e.g. ANSWER_MODULE=/path/to/answer","messagePattern":"failed to clone (.+?)@(.+?): %w\nTip: set ANSWER_MODULE to a local checkout path instead, e\\.g\\. ANSWER_MODULE=/path/to/answer","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/build.go","lineNumber":293,"sourceCode":"\t\treturn replacement, nil\n\t}\n\n\t// Clone the repo to a local directory and return its path.\n\tgitURL := \"https://\" + moduleName\n\ttag := \"v\" + strings.TrimPrefix(version, \"v\")\n\tlocalPath := filepath.Join(filepath.Dir(tmpDir), fmt.Sprintf(\"answer_src_%s\", strings.ReplaceAll(version, \".\", \"_\")))\n\n\tif _, statErr := os.Stat(localPath); statErr == nil {\n\t\tfmt.Printf(\"[build] using cached local clone at %s\\n\", localPath)\n\t\treturn localPath, nil\n\t}\n\n\tfmt.Printf(\"[build] v2+ module detected, cloning %s@%s to local path %s...\\n\", moduleName, version, localPath)\n\tcloneCmd := exec.Command(\"git\", \"clone\", \"--depth=1\", \"--branch=\"+tag, gitURL, localPath)\n\tcloneCmd.Stdout = os.Stdout\n\tcloneCmd.Stderr = os.Stderr\n\tif err = cloneCmd.Run(); err != nil {\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"failed to clone %s@%s: %w\\nTip: set ANSWER_MODULE to a local checkout path instead, e.g. ANSWER_MODULE=/path/to/answer\",\n\t\t\tmoduleName, version, err,\n\t\t)\n\t}\n\n\tfmt.Printf(\"[build] successfully cloned to %s\\n\", localPath)\n\treturn localPath, nil\n}\n\n// movePluginToVendor move plugin to vendor dir\n// Traverse the plugins, and if the plugin path is not github.com/apache/answer-plugins, move the contents of the current plugin to the vendor/github.com/apache/answer-plugins/ directory.\nfunc movePluginToVendor(b *buildingMaterial) (err error) {\n\tpluginsDir := filepath.Join(b.tmpDir, \"vendor/github.com/apache/answer-plugins/\")\n\tfor _, p := range b.plugins {\n\t\tpluginDir := filepath.Join(b.tmpDir, \"vendor/\", p.Name)\n\t\tpluginName := filepath.Base(p.Name)\n\t\tif !strings.HasPrefix(p.Name, \"github.com/apache/answer-plugins/\") {\n\t\t\tfmt.Printf(\"try to copy dir from %s to %s\\n\", pluginDir, filepath.Join(pluginsDir, pluginName))","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/build.go#L275-L311","documentation":"resolveAnswerModuleReplacement (v2+ module path) shells out to `git clone --depth=1 --branch=<tag>` to fetch the answer module source; when the clone command exits nonzero it wraps the git error with a Tip suggesting setting ANSWER_MODULE to a local checkout.","triggerScenarios":"`answer build` resolving a v2+ module: git clone fails because the tag doesn't exist, no network/proxy blocking git access, repo URL unreachable, git not installed, or target localPath already exists and is not empty.","commonSituations":"Building offline/behind corporate proxy, referencing a version tag that hasn't been published, GitHub rate-limit/outage, git missing in CI container images, stale leftover directory from a previous failed build.","solutions":["Set ANSWER_MODULE to a local checkout of the answer repo, e.g. ANSWER_MODULE=/path/to/answer, to skip cloning.","Check network/proxy settings; test `git clone --depth=1 --branch=<tag> <url>` manually.","Verify the tag/version exists in the answer repository (or use a published version).","Ensure git is installed in the build environment and delete any stale target directory before rebuilding."],"exampleFix":"// before\n$ answer build (resolves module by cloning github.com/apache/answer@v2.x)\n// after\n$ export ANSWER_MODULE=/path/to/local/answer\n$ answer build","handlingStrategy":"fallback","validationCode":"git --version && git ls-remote --tags https://github.com/apache/answer.git | grep \"refs/tags/$TAG\" || echo \"tag missing or network blocked\"","typeGuard":null,"tryCatchPattern":"out, err := resolveAnswerModuleReplacement(...)\nif err != nil && strings.Contains(err.Error(), \"failed to clone\") {\n  if local := os.Getenv(\"ANSWER_MODULE\"); local != \"\" {\n    out, err = useLocalCheckout(local)\n  }\n}","preventionTips":["Set ANSWER_MODULE to a local checkout for offline/CI builds","Pre-install git in build images","Verify target version tags exist before building","Clean stale clone target directories between builds","Configure proxy env vars (HTTPS_PROXY) when behind a firewall"],"tags":["build","git","network","go"],"backgroundTag":"git-clone-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}