{"record":{"id":"8556e82fe0a456d0","repo":"asdf-vm/asdf","slug":"usage-asdf-exec-command","errorCode":null,"errorMessage":"usage: asdf exec <command>","messagePattern":"usage: asdf exec <command>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/cli.go","lineNumber":575,"sourceCode":"\t\treturn err\n\t}\n\n\tfinalEnv := execute.MergeWithCurrentEnv(env)\n\terr = exec.Exec(fname, realArgs, finalEnv)\n\tif err != nil {\n\t\tfmt.Printf(\"err %#+v\\n\", err.Error())\n\t}\n\treturn err\n}\n\nfunc setPath(paths []string) string {\n\treturn strings.Join(paths, string(os.PathListSeparator)) + string(os.PathListSeparator) + os.Getenv(\"PATH\")\n}\n\nfunc execCommand(logger *log.Logger, command string, args []string) error {\n\tif command == \"\" {\n\t\tlogger.Printf(\"usage: asdf exec <command>\")\n\t\treturn fmt.Errorf(\"usage: asdf exec <command>\")\n\t}\n\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\texecutable, plugin, version, err := getExecutable(logger, conf, command)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(args) > 1 {\n\t\targs = args[1:]\n\t} else {\n\t\targs = []string{}\n\t}","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/cli/cli.go#L557-L593","documentation":"asdf's exec command returns this error when the command to execute is an empty string. execCommand needs a concrete command to resolve through asdf's version machinery and run; with no command there is nothing to do, so it prints and returns the usage error.","triggerScenarios":"Running `asdf exec` with no arguments, or calling execCommand programmatically with command == \"\".","commonSituations":"Scripting asdf where a variable holding the command is empty (e.g. unset in a shell script); mistyping the invocation so the command argument is dropped.","solutions":["Provide the command: `asdf exec node script.js`.","Check shell scripts for empty/unset variables before invoking `asdf exec $CMD`.","Use `asdf exec` with at least one positional argument after any flags."],"exampleFix":"// before\nCMD=\"\"\nasdf exec $CMD\n// after\nCMD=\"node\"\nasdf exec $CMD --version","handlingStrategy":"validation","validationCode":"if [ -z \"$CMD\" ]; then echo \"usage: asdf exec <command>\" >&2; exit 1; fi\nasdf exec \"$CMD\"","typeGuard":null,"tryCatchPattern":"if ! asdf exec \"$CMD\" \"$@\" 2>err.log; then cat err.log >&2; exit $?; fi","preventionTips":["Pass the command as the first positional argument to asdf exec","Validate variables holding commands are non-empty in scripts","Prefer `asdf exec <cmd> -- args` form to avoid argument confusion"],"tags":["cli","usage","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"074a1722ca88d6677f228541ce06efaf4f9924d4","analyzedAt":"2026-08-30T19:56:42.972Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}