joewalnes/websocketd · error

did you mean to specify COMMAND instead of --dir '%s'?

Error message

did you mean to specify COMMAND instead of --dir '%s'?

What it means

resolveScriptDir finds that the --dir path exists (os.Stat succeeded) but is a regular file, not a directory, and suggests the user probably meant to run it as COMMAND. It disambiguates the common mistake of passing a script file to --dir instead of a directory containing scripts.

Source

Thrown at config.go:226

	}
	return "", nil, nil
}

// resolveScriptDir validates and resolves the script directory path.
func resolveScriptDir(dir string) (string, error) {
	if dir == "" {
		return "", nil
	}
	absDir, err := filepath.Abs(dir)
	if err != nil {
		return "", fmt.Errorf("could not resolve absolute path to dir '%s'", dir)
	}
	inf, err := os.Stat(absDir)
	if err != nil {
		return "", fmt.Errorf("could not find your script dir '%s'", dir)
	}
	if !inf.IsDir() {
		return "", fmt.Errorf("did you mean to specify COMMAND instead of --dir '%s'?", dir)
	}
	return absDir, nil
}

// validateDir checks that a directory path exists and is a directory.
func validateDir(dir, label string) error {
	if dir == "" {
		return nil
	}
	inf, err := os.Stat(dir)
	if err != nil || !inf.IsDir() {
		return fmt.Errorf("your %s '%s' is not pointing to an accessible directory", label, dir)
	}
	return nil
}

func parseCommandLine() *Config {
	var mainConfig Config

View on GitHub (pinned to 7a8683dc7f)

Solutions

  1. If you meant to run one script: drop --dir and pass it as COMMAND (`websocketd ./scripts/count.sh`)
  2. If you meant directory mode: point --dir at the containing directory (`websocketd --dir=./scripts`)

Example fix

// before
websocketd --dir=./scripts/count.sh
// after
websocketd --dir=./scripts        # directory mode
# or
websocketd ./scripts/count.sh     # single command mode
Defensive patterns

Strategy: validation

Validate before calling

inf, err := os.Stat(target)
if err != nil {
	log.Fatal(err)
}
if inf.IsDir() {
	exec.Command("websocketd", "--dir="+target).Run()
} else {
	exec.Command("websocketd", target).Run()
}

Prevention

When it happens

Trigger: `websocketd --dir=./scripts/count.sh` — the path exists but IsDir() is false, so resolveScriptDir returns this hint instead of an ambiguous or not-found error.

Common situations: Passing a single script to --dir out of habit from other tools; tab-completion mistakes; swapping flags when converting a single-script command line to directory mode.

Related errors


AI-assisted analysis of joewalnes/websocketd@7a8683dc7f (2026-09-03). Data as JSON: /api/errors/98399617da1970e7. Report an issue: GitHub.