{"record":{"id":"7ed75e104a26ada7","repo":"golang/go","slug":"error-opening-profile-w","errorCode":null,"errorMessage":"error opening profile: %w","messagePattern":"error opening profile: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/pgoir/irgraph.go","lineNumber":125,"sourceCode":"\tCallee     *ir.Func\n}\n\n// Profile contains the processed PGO profile and weighted call graph used for\n// PGO optimizations.\ntype Profile struct {\n\t// Profile is the base data from the raw profile, without IR attribution.\n\t*pgo.Profile\n\n\t// WeightedCG represents the IRGraph built from profile, which we will\n\t// update as part of inlining.\n\tWeightedCG *IRGraph\n}\n\n// New generates a profile-graph from the profile or pre-processed profile.\nfunc New(profileFile string) (*Profile, error) {\n\tf, err := os.Open(profileFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error opening profile: %w\", err)\n\t}\n\tdefer f.Close()\n\tr := bufio.NewReader(f)\n\n\tisSerialized, err := pgo.IsSerialized(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error processing profile header: %w\", err)\n\t}\n\n\tvar base *pgo.Profile\n\tif isSerialized {\n\t\tbase, err = pgo.FromSerialized(r)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error processing serialized PGO profile: %w\", err)\n\t\t}\n\t} else {\n\t\tbase, err = pgo.FromPProf(r)\n\t\tif err != nil {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/pgoir/irgraph.go#L107-L143","documentation":"The profile-guided optimization (PGO) subsystem opens a profile file via os.Open in pgoir.New(). This error wraps the underlying os.Open failure, which is typically a missing file, wrong path, or permission denied. The %w verb preserves the original error for unwrapping.","triggerScenarios":"Passing -pgo=/path/to/profile or -pgoprofile=/path where the file does not exist, is unreadable due to permissions, or the path is incorrect. The path can be absolute or relative to the working directory.","commonSituations":"CI pipelines where the PGO profile is not checked in or is generated in a different directory. Profile generation step failing or not running before the build step. Wrong working directory when the profile path is relative.","solutions":["Verify the profile file exists at the specified path with os.Stat before building","Use a path relative to the module root, or use an absolute path","Regenerate the profile with: go test -cpuprofile=default.pgo ./...","Check file permissions: ensure the build process can read the profile file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify PGO profile exists and is readable before building\nimport (\n    \"os\"\n)\n\nfunc validatePGOProfile(path string) error {\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"PGO profile not accessible: %w\", err)\n    }\n    if info.Size() == 0 {\n        return fmt.Errorf(\"PGO profile is empty\")\n    }\n    if !info.Mode().IsRegular() {\n        return fmt.Errorf(\"PGO profile is not a regular file\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check that the PGO profile file exists before running go build -pgo","Use go test -cpuprofile to generate profiles rather than constructing them manually","Store profile files in a predictable location relative to the module root","Add the profile file to version control or a reliable artifact store in CI"],"tags":["go-compiler","go-pgo","file-system","configuration"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}