Jguer/yay · error
argument '-' specified without input on stdin
Error message
argument '-' specified without input on stdin
What it means
parseStdin in pkg/settings/parser/parser.go:606 handles the '-' pseudo-argument, which means 'read targets from stdin'. Before reading it checks whether stdin is a character device (an interactive terminal); if so there is no piped input, and it errors with 'argument '-' specified without input on stdin'. It exists so '-' is not silently hung waiting on terminal input.
Solutions
- Pipe input into the command: echo "pkgname" | yay -S - or provide targets directly as arguments.
- Remove the '-' argument if you did not intend stdin-based target reading.
- In scripts, redirect stdin explicitly (cmd < filelist.txt) when using '-'.
- When invoking programmatically, set cmd.Stdin to a buffer/pipe before calling Parse.
Example fix
// before yay -S - # run interactively, nothing on stdin // after echo "ripgrep" | yay -S -
Defensive patterns
Strategy: validation
Validate before calling
// Ensure '-' is only used when stdin is piped
fi, _ := os.Stdin.Stat()
piped := fi != nil && (fi.Mode()&os.ModeCharDevice) == 0
if slices.Contains(args, "-") && !piped {
return errors.New("'-' requires piped stdin: echo pkg | cmd -")
} Try / catch
if err := args.Parse(); err != nil {
if strings.Contains(err.Error(), "specified without input on stdin") {
return usageError("drop '-' or pipe targets into stdin")
}
return err
} Prevention
- Only use '-' when a pipe or redirection feeds stdin
- In scripts, always redirect stdin explicitly when using '-'
- Prefer passing target names as direct arguments in interactive use
- When embedding the parser in tests/tools, wire os.Stdin to a real pipe before Parse
When it happens
Trigger: Parse() is called with the argument '-' while os.Stdin is still attached to the TTY, i.e. no pipe or redirected file is feeding stdin.
Common situations: Typing 'pacman -S -' (or yay equivalent) directly in a terminal instead of piping (e.g. 'echo pkg | pacman -S -'); running the command from a script without redirecting stdin; stdin closed/reopened incorrectly in tests or wrappers.
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 Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/5d7e4b5d7ee48a88.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/settings/parser/parser.go:606
case hasParam(arg):
err = a.addParam(arg, param)
usedNext = true
default:
err = a.AddArg(arg)
}
return
}
func (a *Arguments) parseStdin() error {
fi, err := os.Stdin.Stat()
if err != nil {
return err
}
// Ensure data is piped
if (fi.Mode() & os.ModeCharDevice) != 0 {
return errors.New(gotext.Get("argument '-' specified without input on stdin"))
}
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
a.AddTarget(scanner.Text())
}
if err := scanner.Err(); err != nil {
return err
}
return os.Stdin.Close()
}
func (a *Arguments) Parse() error {
args := os.Args[1:]View on GitHub (pinned to 328f4b4939)