wavetermdev/waveterm · error

reading input file: %w

Error message

reading input file: %w

What it means

When --input is given, debugTermRun loads the capture file with os.ReadFile and wraps any failure (nonexistent path, permission denied, is-a-directory) as 'reading input file'. The file must contain raw debug term data.

Source

Thrown at cmd/wsh/cmd/wshcmd-debugterm.go:78

		stdinData, err := io.ReadAll(WrappedStdin)
		if err != nil {
			return fmt.Errorf("reading stdin: %w", err)
		}
		termData, err := parseDebugTermStdinData(stdinData)
		if err != nil {
			return err
		}
		if mode == DebugTermModeDecode {
			WriteStdout("%s", formatDebugTermDecode(termData))
		} else {
			WriteStdout("%s", formatDebugTermHex(termData))
		}
		return nil
	}
	if debugTermInput != "" {
		fileData, err := os.ReadFile(debugTermInput)
		if err != nil {
			return fmt.Errorf("reading input file: %w", err)
		}
		termData, err := parseDebugTermStdinData(fileData)
		if err != nil {
			return err
		}
		if mode == DebugTermModeDecode {
			WriteStdout("%s", formatDebugTermDecode(termData))
		} else {
			WriteStdout("%s", formatDebugTermHex(termData))
		}
		return nil
	}
	if debugTermSize <= 0 {
		return fmt.Errorf("size must be greater than 0")
	}
	fullORef, err := resolveBlockArg()
	if err != nil {
		return err

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the path exists and is readable: ls -l <path>
  2. Use an absolute path instead of a relative one
  3. Check file permissions or run as a user with read access
  4. Point --input at a file, not a directory

Example fix

// before
wsh debugterm --input capture.bin        # file is in /tmp, cwd is home
// after
wsh debugterm --input /tmp/capture.bin
Defensive patterns

Strategy: validation

Validate before calling

if [ ! -f "$INPUT" ] || [ ! -r "$INPUT" ]; then
  echo "input file missing or unreadable: $INPUT" >&2
  exit 1
fi

Try / catch

fileData, err := os.ReadFile(debugTermInput)
if err != nil {
	return fmt.Errorf("reading input file %q: %w", debugTermInput, err)
}

Prevention

When it happens

Trigger: `wsh debugterm --input <path>` where the path does not exist, is misspelled, has no read permission, or is a directory.

Common situations: Typo in the capture file path; running from a different working directory with a relative path; file created by another user/with restrictive permissions; pointing at a directory instead of a file.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/1a3f7ce2ba3fc7da. Report an issue: GitHub.