go-delve/delve · error
unknown argument %q to 'target follow-exec'
Error message
unknown argument %q to 'target follow-exec'
What it means
`target follow-exec` accepts at most one flag: `-on` (implicit/default), `-off`, or `-regex <pattern>`. Any other token is rejected with this message by the default case.
Source
Thrown at pkg/terminal/command.go:3576
fmt.Fprintf(t.stdout, "Follow exec is disabled.\n")
}
return nil
}
argv = config.Split2PartsBySpace(argv[1])
switch argv[0] {
case "-on":
var regex string
if len(argv) == 2 {
regex = argv[1]
}
t.client.FollowExec(true, regex)
case "-off":
if len(argv) > 1 {
return errors.New("too many arguments")
}
t.client.FollowExec(false, "")
default:
return fmt.Errorf("unknown argument %q to 'target follow-exec'", argv[0])
}
return nil
case "switch":
tgts, err := t.client.ListTargets()
if err != nil {
return err
}
pid, err := strconv.Atoi(argv[1])
if err != nil {
return err
}
found := false
for _, tgt := range tgts {
if tgt.Pid == pid {
found = true
t.client.SwitchThread(tgt.CurrentThread.ID)
}
}View on GitHub (pinned to a23773e6c3)
Solutions
- Use `target follow-exec -regex <pattern>` to filter exec'd children by pattern
- Use `target follow-exec -off` to disable
- Use `target follow-exec -on` (or bare) to enable for all children
- Check flag spelling and case
Example fix
// before target follow-exec server* // after target follow-exec -regex server*
Defensive patterns
Strategy: try-catch
Try / catch
if !validFollowExecArg(argv[0]) {
return fmt.Errorf("%q invalid; use -on, -off, or -regex <pattern>", argv[0])
} Prevention
- Validate subcommand flags against a whitelist
When it happens
Trigger: Running e.g. `target follow-exec -all`, `target follow-exec foo`, or any misspelled flag.
Common situations: Typos (`-of` instead of `-off`); trying to pass an exec pattern directly without the `-regex` flag; muscle memory from other debuggers.
Related errors
- command not available
- you must specify a thread
- too many arguments to goroutine
- not enough arguments
- Invalid frame %d
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/4c16ca4a06b4271b.
Report an issue: GitHub.