charmbracelet/vhs · error · parser.Error

Expected folder with trailing slash

Error message

Expected folder with trailing slash

What it means

Fires in parseOutput when the Output argument has no file extension, so it is treated as a directory (defaulting output format to .png), but the path does not end with '/'. The parser cannot tell whether the target is a folder, so it flags the missing trailing slash.

Source

Thrown at parser/parser.go:431

// 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
}

// parseSet parses a set command.
// A set command takes a setting name and a value.
//
//	Set <setting> <value>
func (p *Parser) parseSet() Command {
	cmd := Command{Type: token.SET}

	if token.IsSetting(p.peek.Type) {
		cmd.Options = p.peek.Literal
	} else {

View on GitHub (pinned to c073383b5d)

Solutions

  1. Append a trailing slash to the folder path, e.g. Output frames/
  2. Add a file extension if a file was intended, e.g. Output out.png or Output out.webm
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at parser/parser.go:431 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/2a3ad50b309a7674. Report an issue: GitHub.