{"record":{"id":"215068621e9a2254","repo":"pulumi/pulumi","slug":"stat-s-w","errorCode":null,"errorMessage":"stat %s: %w","messagePattern":"stat (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/pulumi-language-go/main.go","lineNumber":1701,"sourceCode":"\t\tmodules[modulePath] = dep.Path\n\t\t// The relative path used in the replace directive must start with `./` or `.\\`.\n\t\t// https://go.dev/ref/mod#go-mod-file-replace\n\t\tstart := \"./\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tstart = \".\\\\\"\n\t\t}\n\t\tif !strings.HasPrefix(dep.Path, start) {\n\t\t\tmodules[modulePath] = start + dep.Path\n\t\t}\n\t\tfmt.Fprintf(&imports, \"    \\\"%s\\\"\\n\", codegen.ExtractImportBasePath(pkg.Reference()))\n\t}\n\tinstructions += imports.String()\n\tinstructions += \"  )\\n\"\n\n\tgomodFilepath := filepath.Join(req.Info.ProgramDirectory, \"go.mod\")\n\tstat, err := os.Stat(gomodFilepath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"stat %s: %w\", gomodFilepath, err)\n\t}\n\tgomodFileContent, err := os.ReadFile(gomodFilepath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading go.mod: %w\", err)\n\t}\n\tgomod, err := modfile.Parse(gomodFilepath, gomodFileContent, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"go.mod parse: %w\", err)\n\t}\n\n\tfor modulePath, path := range modules {\n\t\terr = gomod.AddReplace(modulePath, \"\", path, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not add replace statement: %w\", err)\n\t\t}\n\t}\n\n\tdata, err := gomod.Format()","sourceCodeStart":1683,"sourceCodeEnd":1719,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/pulumi-language-go/main.go#L1683-L1719","documentation":"Thrown when generating provider instructions (GetProgramDependencies flow) and os.Stat on the program's go.mod fails. The stat result is also needed later to preserve file permissions when rewriting go.mod, so failure is fatal.","triggerScenarios":"os.Stat(filepath.Join(req.Info.ProgramDirectory, \"go.mod\")) fails because the program directory has no go.mod or is inaccessible.","commonSituations":"ProgramDirectory pointing at a non-Go project or wrong path, program deleted between plugin generation steps, running the language host with a stale ProgramDirectory after a rename.","solutions":["Verify req.Info.ProgramDirectory is the Go program root containing go.mod","Run `go mod init` in the program directory if missing","Fix path/permission problems so the file is stat-able","Re-run the pulumi command after the program directory settles"],"exampleFix":"// before\ncd myprogram/subdir && pulumi up\n// after\ncd myprogram   # directory containing go.mod\npulumi up","handlingStrategy":"validation","validationCode":"gomod := filepath.Join(progDir, \"go.mod\")\nif _, err := os.Stat(gomod); err != nil {\n\treturn fmt.Errorf(\"program %s is not a Go module: %w\", progDir, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm ProgramDirectory is the Go program root","Initialize go.mod before pulumi operations","Avoid moving/renaming the program directory mid-run"],"tags":["go","go-mod","stat","file-not-found"],"backgroundTag":"go-mod-file-not-found","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}