go-delve/delve · error

could not find rule for %q

Error message

could not find rule for %q

What it means

Returned by the `config substitute-path <from>` command (configureSetSubstitutePath) when removing or the rule lookup fails: no entry in t.conf.SubstitutePath has a From field equal to argv[0]. Delve keeps substitute-path rules as an ordered list of {From,To} pairs and only rewrites paths whose prefix exactly matches a stored From.

Source

Thrown at pkg/terminal/config.go:111

		argv = argv[1:]
	}
	switch len(argv) {
	case 0:
		w := new(tabwriter.Writer)
		w.Init(t.stdout, 0, 8, 1, ' ', 0)
		for i := range t.conf.SubstitutePath {
			fmt.Fprintf(w, "%q\t→\t%q\n", t.conf.SubstitutePath[i].From, t.conf.SubstitutePath[i].To)
		}
		w.Flush()
	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

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Run `config substitute-path` with no arguments to list existing rules and copy the From value exactly
  2. Delete the rule with the exact stored From string (watch trailing slashes and absolute vs relative forms)
  3. If you meant to add a brand-new mapping, verify the argument count: two args add/update, one arg deletes
  4. Update to a version that normalizes paths if your workflow relies on path normalization

Example fix

// before
dlv> config substitute-path /home/me/oldproject /home/me/newproject   # fails: rule never existed
// after
dlv> config substitute-path            # list rules first
dlv> config substitute-path /home/me/oldproject       # exact From match deletes it
Defensive patterns

Strategy: validation

Validate before calling

rules = t.conf.SubstitutePath
if not any(r["From"] == argv[0] for r in rules):
    raise ValueError("no substitute-path rule with From=%r; run 'config substitute-path' to list" % argv[0])

Prevention

When it happens

Trigger: Running `config substitute-path /old/path` with 1 argument (delete) or `config substitute-path /old/path /new/path` with 2 arguments (add/update) when no rule whose From equals /old/path exists; also misspelling the From path or using a non-normalized path (trailing slash, relative vs absolute).

Common situations: User tries to delete a rule that was already removed, mistypes the source path, or assumes prefix/partial matching works when only exact string equality against the From field is checked.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/5bfb1a3db0aedc1f. Report an issue: GitHub.