go-delve/delve · error
unknown argument %q to 'target follow-exec'
Error message
unknown argument %q to 'target follow-exec'
What it means
The DAP 'target follow-exec' REPL command only accepts -on [regex], -off, or no argument (status). Any other first argument after 'follow-exec' produces this error. It is strict argument validation for the follow-exec (child process following) subcommand.
Source
Thrown at service/dap/command.go:304
regex = argv[1]
}
if err := s.debugger.FollowExec(true, regex); err != nil {
return "", err
}
if regex != "" {
return fmt.Sprintf("Follow exec mode enabled with regex %q", regex), nil
}
return "Follow exec mode enabled", nil
case "-off":
if len(argv) > 1 {
return "", errors.New("too many arguments")
}
if err := s.debugger.FollowExec(false, ""); err != nil {
return "", err
}
return "Follow exec mode disabled", nil
default:
return "", fmt.Errorf("unknown argument %q to 'target follow-exec'", argv[0])
}
case "switch": // TODO: This may cause inconsistency between debugger and frontend.
tgrp, unlock := s.debugger.LockTargetGroup()
defer unlock()
pid, err := strconv.Atoi(argv[1])
if err != nil {
return "", err
}
found := false
for _, tgt := range tgrp.Targets() {
if _, err = tgt.Valid(); err == nil && tgt.Pid() == pid {
found = true
tgrp.Selected = tgt
tgt.SwitchThread(pid)
}
}
if !found {
return "", fmt.Errorf("could not find target %d", pid)View on GitHub (pinned to a23773e6c3)
Solutions
- Use exactly 'target follow-exec -on [regex]' to enable or 'target follow-exec -off' to disable.
- Call 'target follow-exec' with no argument to see the current status instead of guessing flags.
- Check the command string your frontend builds for misspelled or undashed flags.
- Note extra arguments to -off also fail; pass none.
Example fix
// before target follow-exec enable // after target follow-exec -on // or with regex: target follow-exec -on ^/path/to/child$
Defensive patterns
Strategy: validation
Validate before calling
validArgs := map[string]bool{"-on": true, "-off": true}
if !validArgs[arg] {
return fmt.Errorf("use 'target follow-exec -on [regex]' or '-off', got %q", arg)
} Prevention
- Only use the documented flags -on and -off
- Pass no extra arguments with -off
- Run 'target follow-exec' bare to check current status
When it happens
Trigger: Evaluating 'target follow-exec enable', 'target follow-exec -on extra args misparsed', or any misspelled flag like '-enable'/'-true' via the DAP evaluate/REPL command path.
Common situations: Users habituated to other debuggers typing 'on'/'off' without the dash; IDE extension frontends constructing the command string with wrong flag names; typos such as '-onn' or '--on'.
Related errors
- unknown target command
- follow exec not supported
- follow exec not implemented
- count/len must be a positive integer
- expected argument after -size
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/10464a08c4fd8dae.
Report an issue: GitHub.