pranshuparmar/witr · error
must specify --pid, --port, --file, --container, or a proces
Error message
must specify --pid, --port, --file, --container, or a process name
What it means
runApp validates that at least one inspection target was supplied on the command line. collectTargetsInOrder found no --pid, --port, --file, --container flag or bare process-name argument, so there is nothing to inspect. The CLI returns ExitInvalidInput for this user error.
Source
Thrown at internal/app/app.go:203
return runInteractive()
}
flags := appFlags{
env: envFlag,
exact: boolFlag(cmd, "exact"),
short: boolFlag(cmd, "short"),
tree: boolFlag(cmd, "tree"),
json: boolFlag(cmd, "json"),
warn: boolFlag(cmd, "warnings"),
noColor: boolFlag(cmd, "no-color"),
verbose: boolFlag(cmd, "verbose"),
}
// Collect all targets preserving command-line order
targets := collectTargetsInOrder(os.Args[1:], args, flagTakesValue(cmd))
if len(targets) == 0 {
return withExitCode(ExitInvalidInput, fmt.Errorf("must specify --pid, --port, --file, --container, or a process name"))
}
outw := cmd.OutOrStdout()
outp := output.NewPrinter(outw)
multiMode := len(targets) > 1
colorEnabled := useColor(flags, outw)
// For JSON multi-output, collect all JSON strings and wrap in array
var jsonResults []string
highestExit := ExitOK
for i, t := range targets {
if multiMode && !flags.json {
printDivider(outp, t, colorEnabled, i > 0)
}
exitCode := processTarget(cmd, outw, outp, t, flags, multiMode, &jsonResults)
if exitCode > highestExit {View on GitHub (pinned to dc4fa1da82)
Solutions
- Add a target: pass --pid <pid>, --port <port>, --file <path>, --container <name>, or a bare process name.
- Run with --help to see the exact accepted target flags.
- Check your shell script for an empty/misspelled target variable (e.g. "$PID" unset).
- If scripting, guard against an empty target before invoking the tool.
Example fix
// before $ errlookup // after $ errlookup --pid 1234 $ errlookup --port 8080 $ errlookup myserver
Defensive patterns
Strategy: validation
Validate before calling
args := os.Args[1:]
targeted := false
for _, a := range args {
if strings.HasPrefix(a, "--pid") || strings.HasPrefix(a, "--port") ||
strings.HasPrefix(a, "--file") || strings.HasPrefix(a, "--container") ||
!strings.HasPrefix(a, "-") {
targeted = true
break
}
}
if !targeted {
return errors.New("no target given: pass --pid, --port, --file, --container, or a process name")
} Try / catch
if err := runApp(cmd, args); err != nil {
var ec *ExitCodeError
if errors.As(err, &ec) && ec.Code == ExitInvalidInput {
cmd.Usage()
}
return err
} Prevention
- Always pass at least one target flag or a process name when scripting.
- Check scripts for unset variables that would silently drop the target argument.
- Quote process names and validate they are non-empty before invoking.
When it happens
Trigger: Running the binary with no arguments at all, or with only option flags that take no target (e.g. only --json or --exact), or flags whose values were consumed without matching a target keyword.
Common situations: Typing the tool name alone to 'see usage'; shell scripts that build the command dynamically and end up with an empty target variable; misremembering flag names (e.g. --pids) so no target is recognized.
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 pranshuparmar/witr@dc4fa1da82 (2026-09-01).
Data as JSON: /api/errors/f79b218742a01613.
Report an issue: GitHub.