kovidgoyal/kitty · error

Can only specify one directory to search in

Error message

Can only specify one directory to search in

What it means

The choose-files kitten was given more than one positional directory argument; it accepts at most one starting directory (the second CLI argument to the kitten).

Source

Thrown at kittens/choose_files/main.go:976

	}
	handler.rl = readline.New(lp, readline.RlInit{
		Prompt: "> ", ContinuationPrompt: ". ", Completer: FilePromptCompleter(getcwd),
	})
	handler.search_rl = readline.New(lp, readline.RlInit{DontMarkPrompts: true})
	if err = handler.set_state_from_config(conf, opts); err != nil {
		return 1, err
	}
	handler.result_manager = NewResultManager(handler.err_chan, &handler.state, lp.WakeupMainThread)
	handler.preview_manager = NewPreviewManager(handler.err_chan, &handler.state, lp.WakeupMainThread)
	switch len(args) {
	case 0:
		if default_cwd, err = os.Getwd(); err != nil {
			return
		}
	case 1:
		default_cwd = args[0]
	default:
		return 1, fmt.Errorf("Can only specify one directory to search in")
	}
	default_cwd = utils.Expanduser(default_cwd)
	if default_cwd, err = filepath.Abs(default_cwd); err != nil {
		return
	}

	lp.OnInitialize = func() (string, error) {
		if opts.WritePidTo != "" {
			if err := utils.AtomicWriteFile(opts.WritePidTo, bytes.NewReader([]byte(strconv.Itoa(os.Getpid()))), 0600); err != nil {
				return "", err
			}
		}
		if opts.Title != "" {
			lp.SetWindowTitle(opts.Title)
		}
		lp.RequestCurrentColorScheme()
		return handler.OnInitialize()
	}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Pass a single directory only
  2. Quote paths containing spaces: 'kitten choose_files "my dir"'
  3. Implement multi-root behavior yourself via a wrapper that prompts sequentially

Example fix

# before
kitty +kitten choose_files ~/docs ~/pics
# after
kitty +kitten choose_files ~/docs
Defensive patterns

Strategy: validation

Validate before calling

if len(args) > 1 { fmt.Fprintln(os.Stderr, "usage: choose_files [directory]"); os.Exit(1) }

Prevention

When it happens

Trigger: Running kitty +kitten choose_files dir1 dir2 — args has length > 1.

Common situations: Passing multiple paths expecting a multi-root file picker; quoting bugs that split one path into several words.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/1b6d3cace850a05f. Report an issue: GitHub.