{"record":{"id":"f9d51f9c1e4a287d","repo":"go-delve/delve","slug":"not-an-executable-file","errorCode":null,"errorMessage":"not an executable file","messagePattern":"not an executable file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/api/types.go","lineNumber":18,"sourceCode":"package api\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n\n\t\"github.com/go-delve/delve/pkg/proc\"\n)\n\n// ErrNotExecutable is an error returned when trying\n// to debug a non-executable file.\nvar ErrNotExecutable = errors.New(\"not an executable file\")\n\n// DebuggerState represents the current context of the debugger.\ntype DebuggerState struct {\n\t// PID of the process we are debugging.\n\tPid int\n\t// Command line of the process we are debugging.\n\tTargetCommandLine string\n\t// Running is true if the process is running and no other information can be collected.\n\tRunning bool\n\t// Recording is true if the process is currently being recorded and no other\n\t// information can be collected. While the debugger is in this state\n\t// sending a StopRecording request will halt the recording, every other\n\t// request will block until the process has been recorded.\n\tRecording bool\n\t// Core dumping currently in progress.\n\tCoreDumping bool\n\t// CurrentThread is the currently selected debugger thread.\n\tCurrentThread *Thread `json:\"currentThread,omitempty\"`","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/api/types.go#L1-L36","documentation":"ErrNotExecutable is the sentinel error returned by the debugger when Delve is asked to launch a file that cannot be debugged because it is not a valid executable (wrong format, not compiled, or lacking execute permission). Tests like TestDebugger_LaunchNoMain and TestDebugger_LaunchInvalidFormat assert on it.","triggerScenarios":"`debugger.Execute`/launch with a path pointing to a script, object file, core file, or non-Go binary; a binary compiled without a main package; a file with mode bits lacking +x.","commonSituations":"Pointing launch config `program` at a package directory's source file instead of the built binary; running `dlv exec` on a stripped/foreign-architecture binary; CI artifacts built without execute permissions.","solutions":["Build the target first (go build) and pass the resulting binary to `dlv exec`","chmod +x the file if it merely lacks the execute bit","Verify the binary matches the host GOOS/GOARCH and contains Go symbols","Use `dlv debug`/`dlv test` to let Delve compile the program itself"],"exampleFix":"// before\n{ \"request\": \"launch\", \"mode\": \"exec\", \"program\": \"./main.go\" }\n// after\n{ \"request\": \"launch\", \"mode\": \"exec\", \"program\": \"./bin/app\" }","handlingStrategy":"try-catch","validationCode":"info, err := os.Stat(program)\nif err != nil || info.IsDir() || info.Mode()&0o111 == 0 {\n\t// not launchable as exec; build or chmod first\n}","typeGuard":null,"tryCatchPattern":"st, err := dbg.Execute(...)\nif errors.Is(err, api.ErrNotExecutable) {\n\t// build the binary or fix permissions, then retry\n}","preventionTips":["Always build (go build) before dlv exec","Check the execute bit on CI artifacts","Verify GOOS/GOARCH of the binary matches the host"],"tags":["launch","filesystem","executable"],"backgroundTag":"not-an-executable-file","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}