kovidgoyal/kitty · error
Trying to send data when to pipe is nil
Error message
Trying to send data when to pipe is nil
What it means
send() was called on the kitty font backend before its output pipe was established (k.to == nil), i.e. before start() successfully ran or after the backend died and pipes were torn down. It is a programming-order/lifecycle error inside the choose-fonts kitten.
Source
Thrown at kittens/choose_fonts/backend.go:69
k.cmd.Stdout = k.w
k.json_decoder = json.NewDecoder(k.from)
if err = k.cmd.Start(); err != nil {
return err
}
k.started = true
k.timeout = 60 * time.Second
k.wait_for_exit = make(chan error)
go func() {
k.wait_for_exit <- k.cmd.Wait()
}()
return
}
var kitty_font_backend kitty_font_backend_type
func (k *kitty_font_backend_type) send(v any) error {
if k.to == nil {
return fmt.Errorf("Trying to send data when to pipe is nil")
}
data, err := json.Marshal(v)
if err != nil {
return fmt.Errorf("Could not encode message to kitty with error: %w", err)
}
c := make(chan error)
go func() {
if _, err = k.to.Write(data); err != nil {
c <- fmt.Errorf("Failed to send message to kitty with I/O error: %w", err)
return
}
if _, err = k.to.Write([]byte{'\n'}); err != nil {
c <- fmt.Errorf("Failed to send message to kitty with I/O error: %w", err)
return
}
c <- nil
}()
select {View on GitHub (pinned to 6d5d0c4406)
Solutions
- Ensure start() is called and its error checked before any query()
- If the backend crashed, inspect k.stderr for the subprocess error output
- Verify the kitty executable works: kitty +runpy 'print(1)'
Example fix
// before
kitty_font_backend.send(msg)
// after
if err := kitty_font_backend.start(); err != nil { return err }
kitty_font_backend.send(msg) Defensive patterns
Strategy: type-guard
Validate before calling
if kitty_font_backend.to == nil { if err := kitty_font_backend.start(); err != nil { return err } } Type guard
func backendReady(k *kitty_font_backend_type) bool { return k != nil && k.to != nil } Try / catch
Check readiness via guard; on send error mentioning nil pipe, call start() and retry once.
Prevention
- Always start and error-check the backend before issuing queries
- Monitor the subprocess and surface its stderr on crash
When it happens
Trigger: Calling query() -> send() before kitty_font_backend.start() completed os.Pipe(), or after the subprocess exited and pipes were closed.
Common situations: Kitty's backend subprocess crashed at startup; race where a query is issued before init finishes; broken kitty installation causing immediate subprocess exit.
Related errors
- Failed to find the kitty executable, this kitten requires th
- Could not encode message to kitty with error: %w
- Failed to send message to kitty with I/O error: %w
- The font specification %s is invalid as %s does not contain
- Terminal does not support querying the: %s
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/0c39658351b1b652.
Report an issue: GitHub.