{"record":{"id":"12b0ad4cdf6d05ec","repo":"asdf-vm/asdf","slug":"usage-asdf-env-command","errorCode":null,"errorMessage":"usage: asdf env <command>","messagePattern":"usage: asdf env <command>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/cli.go","lineNumber":513,"sourceCode":"}\n\nfunc formatVersions(versions []string) string {\n\tswitch len(versions) {\n\tcase 0:\n\t\treturn \"______\"\n\tcase 1:\n\t\treturn versions[0]\n\tdefault:\n\t\treturn strings.Join(versions, \" \")\n\t}\n}\n\nfunc envCommand(logger *log.Logger, shimmedCommand string, args []string) error {\n\tcommand := \"env\"\n\n\tif shimmedCommand == \"\" {\n\t\tlogger.Printf(\"usage: asdf env <command>\")\n\t\treturn fmt.Errorf(\"usage: asdf env <command>\")\n\t}\n\n\tif len(args) >= 2 {\n\t\tcommand = args[1]\n\t}\n\n\trealArgs := []string{}\n\tif len(args) > 2 {\n\t\trealArgs = args[2:]\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\t_, plugin, version, err := getExecutable(logger, conf, shimmedCommand)","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/cli/cli.go#L495-L531","documentation":"asdf's env command prints usage and returns this error when it is invoked without a shimmed command to wrap. envCommand requires a non-empty shimmedCommand argument (the tool command whose environment should be reproduced); without it there is nothing to build an environment for, so the CLI aborts with the usage message.","triggerScenarios":"Running `asdf env` with no arguments, or invoking the env subcommand programmatically with shimmedCommand == \"\".","commonSituations":"Typing `asdf env` expecting to dump the current environment instead of a specific tool's; shell scripts calling asdf env without the required positional argument.","solutions":["Pass the tool command as an argument, e.g. `asdf env node` to print the environment asdf would use for node.","Run `asdf env --help` or `asdf help` to see required arguments.","In scripts, ensure the shimmed command variable is non-empty before calling `asdf env $CMD`."],"exampleFix":"// before\nasdf env\n// after\nasdf env node","handlingStrategy":"validation","validationCode":"if [ -z \"$1\" ]; then echo \"usage: asdf env <command>\" >&2; exit 1; fi\nasdf env \"$1\"","typeGuard":null,"tryCatchPattern":"if ! asdf env \"$CMD\" 2>err.log; then cat err.log >&2; fi","preventionTips":["Always pass the shimmed tool command to asdf env","Check `asdf env --help` for argument order","In scripts, assert the command variable is non-empty before invoking"],"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"}