{"record":{"id":"91dbc5757e8f4099","repo":"asdf-vm/asdf","slug":"must-provide-command","errorCode":null,"errorMessage":"must provide command","messagePattern":"must provide command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/cli.go","lineNumber":1445,"sourceCode":"}\n\n// This function is a whole mess and needs to be refactored\nfunc whichCommand(logger *log.Logger, command string) error {\n\tconf, err := config.LoadConfig()\n\tif err != nil {\n\t\tlogger.Printf(\"error loading config: %s\", err)\n\t\treturn err\n\t}\n\n\tcurrentDir, err := os.Getwd()\n\tif err != nil {\n\t\tlogger.Printf(\"unable to get current directory: %s\", err)\n\t\treturn err\n\t}\n\n\tif command == \"\" {\n\t\tfmt.Println(\"usage: asdf which <command>\")\n\t\treturn errors.New(\"must provide command\")\n\t}\n\n\tpath, _, _, _, err := shims.FindExecutable(conf, command, currentDir)\n\tif _, ok := err.(shims.UnknownCommandError); ok {\n\t\tlogger.Printf(\"unknown command: %s. Perhaps you have to reshim?\", command)\n\t\treturn errors.New(\"command not found\")\n\t}\n\n\tif _, ok := err.(shims.NoExecutableForPluginError); ok {\n\t\tlogger.Printf(\"%s\", err.Error())\n\t\treturn errors.New(\"no executable for tool version\")\n\t}\n\n\tif err != nil {\n\t\tfmt.Printf(\"unexpected error: %s\\n\", err.Error())\n\t\treturn err\n\t}\n","sourceCodeStart":1427,"sourceCodeEnd":1463,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/cli/cli.go#L1427-L1463","documentation":"`asdf which <command>` needs a command name to locate the shim/executable for. If the command argument is empty, it prints usage and returns this error.","triggerScenarios":"Running `asdf which` with no argument (cmd arg empty), so the guard `if command == \"\"` fires.","commonSituations":"Forgetting the argument when checking where a binary resolves; scripts where the command variable is empty because the tool wasn't specified.","solutions":["Provide the command name: `asdf which node`","Add a default or argument check in scripts calling asdf which","Use `asdf which <command>` only after confirming the tool is installed and reshimmed"],"exampleFix":"// before\n$ asdf which\n// after\n$ asdf which node","handlingStrategy":"validation","validationCode":"CMD=\"$1\"\nif [ -z \"$CMD\" ]; then\n  echo \"usage: asdf which <command>\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"path=$(asdf which \"$CMD\" 2>/dev/null) || {\n  echo \"could not resolve $CMD\" >&2\n}","preventionTips":["Always supply the command argument; asdf which takes no default","In scripts, validate $# >= 1 before invoking","Remember `command -v` is a different tool — asdf which needs the command name, not a path"],"tags":["cli","missing-argument","which"],"backgroundTag":"missing-required-argument","analyzedSha":"074a1722ca88d6677f228541ce06efaf4f9924d4","analyzedAt":"2026-08-30T19:56:42.972Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}