{"record":{"id":"6b16611a4ac1e9c1","repo":"hashicorp/terraform","slug":"cannot-search-s-s","errorCode":null,"errorMessage":"cannot search %s: %s","messagePattern":"cannot search (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/filesystem_search.go","lineNumber":51,"sourceCode":"\t// potentially keep their plugins in a non-standard location but use a\n\t// symlink to help Terraform find them anyway.\n\toriginalBaseDir := baseDir\n\tif finalDir, err := filepath.EvalSymlinks(baseDir); err == nil {\n\t\tif finalDir != filepath.Clean(baseDir) {\n\t\t\tlog.Printf(\"[TRACE] getproviders.SearchLocalDirectory: using %s instead of %s\", finalDir, baseDir)\n\t\t}\n\t\tbaseDir = finalDir\n\t} else {\n\t\t// We'll eat this particular error because if we're somehow able to\n\t\t// find plugins via baseDir below anyway then we'd rather do that than\n\t\t// hard fail, but we'll log it in case it's useful for diagnosing why\n\t\t// discovery didn't produce the expected outcome.\n\t\tlog.Printf(\"[TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for %s: %s\", baseDir, err)\n\t}\n\n\terr := filepath.Walk(baseDir, func(fullPath string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot search %s: %s\", fullPath, err)\n\t\t}\n\n\t\t// There are two valid directory structures that we support here...\n\t\t// Unpacked: registry.terraform.io/hashicorp/aws/2.0.0/linux_amd64 (a directory)\n\t\t// Packed:   registry.terraform.io/hashicorp/aws/terraform-provider-aws_2.0.0_linux_amd64.zip (a file)\n\t\t//\n\t\t// Both of these give us enough information to identify the package\n\t\t// metadata.\n\t\tfsPath, err := filepath.Rel(baseDir, fullPath)\n\t\tif err != nil {\n\t\t\t// This should never happen because the filepath.Walk contract is\n\t\t\t// for the paths to include the base path.\n\t\t\tlog.Printf(\"[TRACE] getproviders.SearchLocalDirectory: ignoring malformed path %q during walk: %s\", fullPath, err)\n\t\t\treturn nil\n\t\t}\n\t\trelPath := filepath.ToSlash(fsPath)\n\t\tparts := strings.Split(relPath, \"/\")\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/filesystem_search.go#L33-L69","documentation":"Raised inside the filepath.Walk callback in SearchLocalDirectory (internal/getproviders/filesystem_search.go:51). When the walk cannot access a path (the 'err' argument to the visit function is non-nil), it is wrapped as 'cannot search <path>: <err>'. Causes include permission denied, a broken/dangling symlink in the hierarchy, or the directory disappearing mid-walk. The error aborts the whole scan.","triggerScenarios":"Scanning a filesystem provider mirror directory that contains a path Go's walker cannot stat or read: a dangling symlink, a permission-restricted subdirectory, or a path deleted during the walk. Triggered by any terraform init / provider discovery that uses a local mirror.","commonSituations":"A plugin filesystem mirror (CLI plugin_cache_dir or filesystem_mirror) with restrictive permissions; a broken symlink left by a failed download; a network mount that dropped mid-scan.","solutions":["Fix filesystem permissions so the Terraform process can read the entire mirror tree (e.g. chmod -R +rX on the mirror directory).","Find and remove or repair dangling symlinks in the mirror hierarchy.","Confirm the mirror directory path configured in the CLI config actually exists and is stable during the scan.","If a path is intentionally inaccessible, exclude it or move the mirror to a clean location."],"exampleFix":"# before: mirror dir not readable by terraform process\n# after\nchmod -R a+rX /opt/terraform-plugins","handlingStrategy":"try-catch","validationCode":"// Verify the mirror directory is walkable before scanning.\nfunc walkable(dir string) error {\n\tinfo, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !info.IsDir() {\n\t\treturn fmt.Errorf(\"%s is not a directory\", dir)\n\t}\n\t// Attempt a representative read to surface permission errors early.\n\tf, err := os.Open(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.Close()\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"found, err := getproviders.SearchLocalDirectory(mirrorDir)\nif err != nil {\n    return fmt.Errorf(\"cannot scan provider mirror %s (check permissions/symlinks): %w\", mirrorDir, err)\n}","preventionTips":["Ensure the Terraform process has read+execute permissions across the whole mirror tree.","Remove dangling symlinks from the mirror hierarchy (only the top-level dir may be a symlink).","Point the mirror at a stable local directory, not a flaky network mount."],"tags":["filesystem","provider-mirror","permissions","io"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}