asdf-vm/asdf · error

must provide command

Error message

must provide command

What it means

`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.

Source

Thrown at internal/cli/cli.go:1445

}

// This function is a whole mess and needs to be refactored
func whichCommand(logger *log.Logger, command string) error {
	conf, err := config.LoadConfig()
	if err != nil {
		logger.Printf("error loading config: %s", err)
		return err
	}

	currentDir, err := os.Getwd()
	if err != nil {
		logger.Printf("unable to get current directory: %s", err)
		return err
	}

	if command == "" {
		fmt.Println("usage: asdf which <command>")
		return errors.New("must provide command")
	}

	path, _, _, _, err := shims.FindExecutable(conf, command, currentDir)
	if _, ok := err.(shims.UnknownCommandError); ok {
		logger.Printf("unknown command: %s. Perhaps you have to reshim?", command)
		return errors.New("command not found")
	}

	if _, ok := err.(shims.NoExecutableForPluginError); ok {
		logger.Printf("%s", err.Error())
		return errors.New("no executable for tool version")
	}

	if err != nil {
		fmt.Printf("unexpected error: %s\n", err.Error())
		return err
	}

View on GitHub (pinned to 074a1722ca)

Solutions

  1. Provide the command name: `asdf which node`
  2. Add a default or argument check in scripts calling asdf which
  3. Use `asdf which <command>` only after confirming the tool is installed and reshimmed

Example fix

// before
$ asdf which
// after
$ asdf which node
Defensive patterns

Strategy: validation

Validate before calling

CMD="$1"
if [ -z "$CMD" ]; then
  echo "usage: asdf which <command>" >&2
  exit 1
fi

Try / catch

path=$(asdf which "$CMD" 2>/dev/null) || {
  echo "could not resolve $CMD" >&2
}

Prevention

When it happens

Trigger: Running `asdf which` with no argument (cmd arg empty), so the guard `if command == ""` fires.

Common situations: Forgetting the argument when checking where a binary resolves; scripts where the command variable is empty because the tool wasn't specified.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of asdf-vm/asdf@074a1722ca (2026-08-30). Data as JSON: /api/errors/91dbc5757e8f4099. Report an issue: GitHub.