{"record":{"id":"4846d4e5108d489a","repo":"junegunn/fzf","slug":"could-not-create-cpu-profile-w","errorCode":null,"errorMessage":"could not create CPU profile: %w","messagePattern":"could not create CPU profile: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options_pprof.go","lineNumber":19,"sourceCode":"//go:build pprof\n// +build pprof\n\npackage fzf\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"runtime\"\n\t\"runtime/pprof\"\n\n\t\"github.com/junegunn/fzf/src/util\"\n)\n\nfunc (o *Options) initProfiling() error {\n\tif o.CPUProfile != \"\" {\n\t\tf, err := os.Create(o.CPUProfile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not create CPU profile: %w\", err)\n\t\t}\n\n\t\tif err := pprof.StartCPUProfile(f); err != nil {\n\t\t\treturn fmt.Errorf(\"could not start CPU profile: %w\", err)\n\t\t}\n\n\t\tutil.AtExit(func() {\n\t\t\tpprof.StopCPUProfile()\n\t\t\tif err := f.Close(); err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, \"Error: closing cpu profile:\", err)\n\t\t\t}\n\t\t})\n\t}\n\n\tstopProfile := func(name string, f *os.File) {\n\t\tif err := pprof.Lookup(name).WriteTo(f, 0); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error: could not write %s profile: %v\\n\", name, err)\n\t\t}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options_pprof.go#L1-L37","documentation":"In a pprof-enabled build (go build -tags=pprof), fzf failed to create the output file for the CPU profile given via --profile-cpu. The wrapped OS error (permission denied, no such directory, etc.) tells you why os.Create failed.","triggerScenarios":"Passing --profile-cpu /path/cpu.prof where the directory does not exist, is not writable, or the path is a directory itself; initProfiling runs during option initialization and aborts startup.","commonSituations":"Profiling into a temp dir that was cleaned up; profiling paths with typos; running as a user without write access to the target directory.","solutions":["Create the parent directory first: mkdir -p /tmp/prof","Point --profile-cpu at an existing writable directory","Check the wrapped error text for the exact OS reason"],"exampleFix":"# before\nfzf --profile-cpu /nonexistent/cpu.prof\n# after\nmkdir -p /tmp/prof && fzf --profile-cpu /tmp/prof/cpu.prof","handlingStrategy":"validation","validationCode":"prof_dir=/tmp/fzf-prof; mkdir -p \"$prof_dir\" && [ -w \"$prof_dir\" ] || exit 1\nfzf --profile-cpu \"$prof_dir/cpu.prof\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["mkdir -p the profile directory in the same command","Use absolute paths so cwd changes cannot break profiling"],"tags":["fzf","pprof","profiling","filesystem"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}