sinelaw/fresh · error

No data piped to stdin

Error message

No data piped to stdin

What it means

The editor was invoked with --stdin or a '-' file argument, expecting piped data on stdin, but stdin is a terminal (no piped input available). It reports the problem on stderr and bails with an InvalidInput io::Error. There is nothing to read, so the operation cannot proceed.

Solutions

  1. Pipe data into the command: `cat file.txt | fresh -` or `command-that-outputs | fresh --stdin`
  2. Remove --stdin/'-' if you intended to open a file normally
  3. In scripts, verify the upstream producer emits data before invoking the editor
  4. When interactive use is intended, open the file directly rather than via stdin mode

Example fix

// before
fresh -
// after
cat file.txt | fresh -
# or open the file directly:
fresh file.txt
Defensive patterns

Strategy: validation

Validate before calling

use std::io::IsTerminal;
if std::io::stdin().is_terminal() {
    eprintln!("--stdin requires piped input");
    std::process::exit(2);
}

Type guard

fn stdin_is_piped() -> bool {
    use std::io::IsTerminal;
    !std::io::stdin().is_terminal()
}

Try / catch

match editor::launch(args) {
    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => eprintln!("pipe data in: cat file | fresh -"),
    Err(e) => eprintln!("{e}"),
    Ok(()) => {},
}

Prevention

When it happens

Trigger: Running `fresh --stdin` or `fresh -` directly in an interactive terminal without piping anything into it, e.g. `fresh -` instead of `cat file | fresh -`.

Common situations: Forgetting the pipe when testing stdin mode; running the command from an IDE run-config or cron where no pipe is attached; a script's upstream command produced no output yet stdin is still a TTY.

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 sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/9427dda07b3529fb. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/src/main.rs:1738

    let stdin_stream = if stdin_requested {
        if stdin_has_data() {
            tracing::info!("Starting background stdin streaming");
            match start_stdin_streaming() {
                Ok(stream_state) => {
                    tracing::info!(
                        "Stdin streaming started, spool: {:?}",
                        stream_state.spool.path()
                    );
                    Some(stream_state)
                }
                Err(e) => {
                    eprintln!("Error: Failed to start stdin streaming: {}", e);
                    return Err(e);
                }
            }
        } else {
            eprintln!("Error: --stdin or \"-\" specified but stdin is a terminal (no piped data)");
            anyhow::bail!(io::Error::new(
                io::ErrorKind::InvalidInput,
                "No data piped to stdin",
            ));
        }
    } else {
        None
    };

    // Determine working directory early for config loading
    // Filter out "-" from files list since it's handled via stdin_stream
    // Parse locations which may be local or remote (user@host:path)
    let parsed_locations: Vec<ParsedLocation> = args
        .files
        .iter()
        .filter(|f| *f != "-")
        .map(|f| parse_location(f))
        .collect::<AnyhowResult<Vec<_>>>()?;

View on GitHub (pinned to 67894ca546)