kovidgoyal/kitty · error

%s is not a valid path with error: %w

Error message

%s is not a valid path with error: %w

What it means

While preparing the screenshot payload, kitty @ could not convert the given output path to an absolute path (filepath.Abs failed after Expanduser). This is a local filesystem error on the client side, before kitty is even contacted.

Source

Thrown at tools/cmd/at/screenshot.go:39

}

func read_screenshot_args(io_data *rc_io_data, args []string) (func(io_data *rc_io_data) (bool, error), error) {
	if len(args) > 1 {
		return nil, fmt.Errorf("%s", "Must specify at most one output file")
	}
	if len(args) == 0 {
		// kitty writes the screenshot directly to the output file when one is
		// given (it runs on the same computer as kitty), so a custom response
		// handler is only needed to write the PNG data to STDOUT.
		io_data.handle_response = screenshot_handle_response
	}
	return func(io_data *rc_io_data) (bool, error) {
		// io_data.rc.Payload is only populated after this generator is created,
		// so the payload field must be set here rather than above.
		if len(args) == 1 {
			path, err := filepath.Abs(utils.Expanduser(args[0]))
			if err != nil {
				return false, fmt.Errorf("%s is not a valid path with error: %w", args[0], err)
			}
			set_payload_string_field(io_data, "Output_path", path)
		}
		return true, nil
	}, nil
}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Check that your current working directory still exists and is accessible (pwd)
  2. Use an absolute path for the output file to sidestep Abs() resolution
  3. Ensure ~ expands to a valid, writable home directory
Defensive patterns

Strategy: validation

Validate before calling

if _, err := filepath.Abs(p); err != nil { /* use an explicit absolute path instead */ }

Try / catch

if err != nil && strings.Contains(err.Error(), "not a valid path") { /* retry with an absolute path */ }

Prevention

When it happens

Trigger: The payload generator calls filepath.Abs(utils.Expanduser(args[0])); failure typically means getwd failed or the expanded path is invalid on this OS.

Common situations: Current directory has been deleted out from under the shell, exotic paths after ~ expansion, or permission problems on the working directory in restricted environments.

Related errors


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