{"record":{"id":"1a917f5c082ac0df","repo":"kovidgoyal/kitty","slug":"you-must-specify-exactly-two-files-directories-to","errorCode":null,"errorMessage":"You must specify exactly two files/directories to compare","messagePattern":"You must specify exactly two files/directories to compare","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/diff/main.go","lineNumber":127,"sourceCode":"\nfunc get_remote_file(path string) (string, error) {\n\tif strings.HasPrefix(path, \"ssh:\") {\n\t\tparts := strings.SplitN(path, \":\", 3)\n\t\tif len(parts) == 3 {\n\t\t\treturn get_ssh_file(parts[1], parts[2])\n\t\t}\n\t}\n\treturn path, nil\n}\n\nfunc main(_ *cli.Command, opts_ *Options, args []string) (rc int, err error) {\n\topts = opts_\n\tconf, err = load_config(opts)\n\tif err != nil {\n\t\treturn 1, err\n\t}\n\tif len(args) != 2 {\n\t\treturn 1, fmt.Errorf(\"You must specify exactly two files/directories to compare\")\n\t}\n\tif err = set_diff_command(conf.Diff_cmd); err != nil {\n\t\treturn 1, err\n\t}\n\tswitch conf.Color_scheme {\n\tcase Color_scheme_light:\n\t\tuse_light_colors = true\n\tcase Color_scheme_dark:\n\t\tuse_light_colors = false\n\tcase Color_scheme_auto:\n\t\tuse_light_colors = false\n\t}\n\tinit_caches()\n\tdefer func() {\n\t\tfor tdir := range remote_dirs {\n\t\t\tos.RemoveAll(tdir)\n\t\t}\n\t}()","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/diff/main.go#L109-L145","documentation":"This error is raised by the diff kitten's main function when the command line does not contain exactly two positional arguments. The diff kitten is invoked as `kitty +kitten diff <left> <right>` and the argument count is validated after config loading, before any diffing starts. Any invocation with zero, one, or more than two paths fails immediately with exit code 1.","triggerScenarios":"Running `kitty +kitten diff` with no arguments, one path, or three or more paths; passing flags after positional args incorrectly so the parser sees the wrong number of positionals; wrapping the kitten in a script that drops or adds an argument.","commonSituations":"Shell scripts that pass unquoted/unexpanded variables (e.g. an empty $file variable) so one path disappears; users assuming the kitten diffs against a git ref or STDIN like `git diff`; typos where a flag is passed without its value, shifting positional parsing.","solutions":["Check the invocation: it must be exactly `kitty +kitten diff <path1> <path2>`.","If scripting, quote variables and verify they are non-empty before calling the kitten.","If you meant to diff git revisions, expand them to two files/directories first (e.g. via git worktree or temp checkouts) and pass those paths."],"exampleFix":"# before\nkitty +kitten diff \"$left\"\n\n# after\nkitty +kitten diff \"$left\" \"$right\"","handlingStrategy":"validation","validationCode":"// Go: validate before invoking the kitten\nif len(paths) != 2 {\n    return fmt.Errorf(\"need exactly two paths, got %d\", len(paths))\n}\nfor _, p := range paths {\n    if strings.TrimSpace(p) == \"\" {\n        return fmt.Errorf(\"empty path argument\")\n    }\n}\ncmd := exec.Command(\"kitty\", \"+kitten\", \"diff\", paths[0], paths[1])","typeGuard":null,"tryCatchPattern":"Check the exit status and stderr of the kitty process; a message starting with 'You must specify exactly two' is a usage bug in the caller, so fix the invocation rather than retrying.","preventionTips":["Always pass exactly two quoted, non-empty path arguments.","Validate argument count in wrapper scripts before exec.","Read the kitten's stderr to distinguish usage errors from real failures."],"tags":["kitty","diff-kitten","cli-arguments","usage-error"],"backgroundTag":"invalid-command-line-arguments","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}