{"record":{"id":"d2ee445434910628","repo":"go-delve/delve","slug":"you-must-provide-a-pid","errorCode":null,"errorMessage":"you must provide a PID","messagePattern":"you must provide a PID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dlv/cmds/commands.go","lineNumber":183,"sourceCode":"\tmust(rootCommand.RegisterFlagCompletionFunc(\"backend\", cobra.FixedCompletions([]string{\"default\", \"native\", \"lldb\", \"rr\"}, cobra.ShellCompDirectiveNoFileComp)))\n\trootCommand.PersistentFlags().StringArrayVarP(&redirects, \"redirect\", \"r\", []string{}, \"Specifies redirect rules for target process (see 'dlv help redirect')\")\n\tmust(rootCommand.MarkPersistentFlagFilename(\"redirect\"))\n\trootCommand.PersistentFlags().BoolVar(&allowNonTerminalInteractive, \"allow-non-terminal-interactive\", false, \"Allows interactive sessions of Delve that don't have a terminal as stdin, stdout and stderr\")\n\trootCommand.PersistentFlags().BoolVar(&disableASLR, \"disable-aslr\", false, \"Disables address space randomization\")\n\n\t// 'attach' subcommand.\n\tattachCommand := &cobra.Command{\n\t\tUse:   \"attach pid [executable]\",\n\t\tShort: \"Attach to running process and begin debugging.\",\n\t\tLong: `Attach to an already running process and begin debugging it.\n\nThis command will cause Delve to take control of an already running process, and\nbegin a new debug session.  When exiting the debug session you will have the\noption to let the process continue or kill it.\n`,\n\t\tPersistentPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 0 && attachWaitFor == \"\" {\n\t\t\t\treturn errors.New(\"you must provide a PID\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRun: attachCmd,\n\t\tValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn nil, cobra.ShellCompDirectiveNoFileComp\n\t\t\t}\n\t\t\treturn nil, cobra.ShellCompDirectiveDefault\n\t\t},\n\t}\n\tattachCommand.Flags().BoolVar(&continueOnStart, \"continue\", false, \"Continue the debugged process on start.\")\n\tattachCommand.Flags().StringVar(&attachWaitFor, \"waitfor\", \"\", \"Wait for a process with a name beginning with this prefix\")\n\tmust(attachCommand.RegisterFlagCompletionFunc(\"waitfor\", cobra.NoFileCompletions))\n\tattachCommand.Flags().Float64Var(&attachWaitForInterval, \"waitfor-interval\", 1, \"Interval between checks of the process list, in millisecond\")\n\tmust(attachCommand.RegisterFlagCompletionFunc(\"waitfor-interval\", cobra.NoFileCompletions))\n\tattachCommand.Flags().Float64Var(&attachWaitForDuration, \"waitfor-duration\", 0, \"Total time to wait for a process\")\n\tmust(attachCommand.RegisterFlagCompletionFunc(\"waitfor-duration\", cobra.NoFileCompletions))","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/cmd/dlv/cmds/commands.go#L165-L201","documentation":"Error \"you must provide a PID\" thrown in go-delve/delve.","triggerScenarios":"Thrown at cmd/dlv/cmds/commands.go:183 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}