charmbracelet/vhs · error · parser.Error

Expected file path after output

Error message

Expected file path after output

What it means

Fires in parseOutput when the token following the Output command is not a STRING, i.e. no file path (or folder path) was supplied for where the recording should be written. The command is returned with no destination and the error is recorded against the current token.

Source

Thrown at parser/parser.go:421

// A keypress command takes an optional typing speed and optional count.
//
//	Key[@<time>] [count]
func (p *Parser) parseKeypress(ct token.Type) Command {
	cmd := Command{Type: CommandType(ct)}
	cmd.Options = p.parseSpeed()
	cmd.Args = p.parseRepeat()
	return cmd
}

// parseOutput parses an output command.
// An output command takes a file path to which to output.
//
//	Output <path>
func (p *Parser) parseOutput() Command {
	cmd := Command{Type: token.OUTPUT}

	if p.peek.Type != token.STRING {
		p.errors = append(p.errors, NewError(p.cur, "Expected file path after output"))
		return cmd
	}

	ext := filepath.Ext(p.peek.Literal)
	if ext != "" {
		cmd.Options = ext
	} else {
		cmd.Options = ".png"
		if !strings.HasSuffix(p.peek.Literal, "/") {
			p.errors = append(p.errors, NewError(p.peek, "Expected folder with trailing slash"))
		}
	}

	cmd.Args = p.peek.Literal
	p.nextToken()
	return cmd
}

View on GitHub (pinned to c073383b5d)

Solutions

  1. Add a destination after Output, e.g. Output out.png or Output frames/
  2. Quote the path if it contains characters the lexer would tokenize differently
  3. Remove the Output line if no output file is wanted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at parser/parser.go:421 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of charmbracelet/vhs@c073383b5d (2026-09-02). Data as JSON: /api/errors/fe22ca4e49969c0a. Report an issue: GitHub.