go-delve/delve · error
too many arguments to "config substitute-path"
Error message
too many arguments to "config substitute-path"
What it means
This error is thrown by Delve's terminal configuration handler when the `config substitute-path` command is given more than two whitespace-separated arguments. The command only supports: no arguments (list rules), one argument (delete the rule whose From matches), or two arguments (add/update a From→To mapping). Anything else falls into the `default` branch of the length switch in configureSetSubstitutePath.
Source
Thrown at pkg/terminal/config.go:121
case 1: // delete substitute-path rule
for i := range t.conf.SubstitutePath {
if t.conf.SubstitutePath[i].From == argv[0] {
copy(t.conf.SubstitutePath[i:], t.conf.SubstitutePath[i+1:])
t.conf.SubstitutePath = t.conf.SubstitutePath[:len(t.conf.SubstitutePath)-1]
return nil
}
}
return fmt.Errorf("could not find rule for %q", argv[0])
case 2: // add substitute-path rule
for i := range t.conf.SubstitutePath {
if t.conf.SubstitutePath[i].From == argv[0] {
t.conf.SubstitutePath[i].To = argv[1]
return nil
}
}
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{From: argv[0], To: argv[1]})
default:
return errors.New("too many arguments to \"config substitute-path\"")
}
return nil
}
func configureSetAlias(t *Term, rest string) error {
argv := config.SplitQuotedFields(rest, '"')
switch len(argv) {
case 1: // delete alias rule
for k := range t.conf.Aliases {
v := t.conf.Aliases[k]
for i := range v {
if v[i] == argv[0] {
copy(v[i:], v[i+1:])
t.conf.Aliases[k] = v[:len(v)-1]
}
}
}
case 2: // add alias ruleView on GitHub (pinned to a23773e6c3)
Solutions
- Split multiple mappings into separate commands: `config substitute-path /from /to` then `config substitute-path /from2 /to2`.
- Quote paths containing spaces: `config substitute-path "/my from" "/my to"` so SplitQuotedFields counts exactly two tokens.
- Run `config substitute-path` with no arguments to list current rules and confirm syntax before modifying.
Example fix
// before dlv: config substitute-path /old/path /new/path /old/path2 /new/path2 // after dlv: config substitute-path /old/path /new/path dlv: config substitute-path /old/path2 /new/path2
Defensive patterns
Strategy: validation
Validate before calling
parts := config.SplitQuotedFields(rest, '"')
if len(parts) > 2 {
return fmt.Errorf("substitute-path takes at most 2 args, got %d", len(parts))
} Prevention
- Quote paths containing spaces so tokenization yields exactly two fields
- Run `config substitute-path` with no args first to inspect existing rules
- Issue one command per From/To mapping
When it happens
Trigger: Running `config substitute-path A B C` (three or more arguments) in the Delve CLI, e.g. trying to add multiple mappings in a single command or accidentally leaving an extra token such as a trailing quoted path or a stray character in the rest string.
Common situations: Users paste multi-rule mappings from docs or scripts as one command; shell-style multi-assignment habits (`from to from2 to2`) carried over from other tools; quoting mistakes in paths with spaces causing SplitQuotedFields to produce extra tokens.
Related errors
- not enough arguments to "config debug-info-directories"
- wrong argument to "config debug-info-directories"
- command not available
- you must specify a thread
- too many arguments to goroutine
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/50bac5744331e72e.
Report an issue: GitHub.