Skip to content

A YAML file Keystone can't read

pandoc.yaml, shortcuts.yaml and fonts/fonts-registry.yaml are read before any chapter, and the build stops when it has no permission to read one, or one does not parse, holds more than one document or sets a key twice, or Pandoc can't read pandoc.yaml as metadata.

What it looks like

ERROR: pandoc.yaml contains invalid YAML
  │ Error: bad file 'pandoc.yaml': go-yaml load error in parser (while parsing a flow sequence) at L1.C8-L2.C1: did not find expected ',' or ']'
  Fix the syntax error.
  See https://keystone.knight-owl.dev/errors/invalid-yaml/#your-metadata-file-doesnt-parse
ERROR: shortcuts.yaml contains invalid YAML
  │ Error: bad file 'shortcuts.yaml': go-yaml load error in scanner (while scanning for the next token) at L3.C1: found character that cannot start any token
  Fix the syntax error, or remove the file.
  See https://keystone.knight-owl.dev/errors/invalid-yaml/#your-shortcuts-file-doesnt-parse
ERROR: fonts/fonts-registry.yaml contains invalid YAML
  │ Error: bad file 'fonts/fonts-registry.yaml': go-yaml load error in scanner (while scanning a quoted scalar) at L2.C13-L3.C1: found unexpected end of stream
  Fix the syntax error, or remove the file.
  See https://keystone.knight-owl.dev/errors/invalid-yaml/#your-font-registry-doesnt-parse
ERROR: pandoc.yaml holds more than one YAML document
  Remove each '---' line that starts another document.
  See https://keystone.knight-owl.dev/errors/invalid-yaml/#your-file-holds-more-than-one-document
ERROR: the build has no permission to read pandoc.yaml
  │ Error: open pandoc.yaml: permission denied
  Give your user read access to the file.
  See https://keystone.knight-owl.dev/errors/invalid-yaml/#the-build-has-no-permission-to-read-your-file

What it means

In a file that doesn't parse, the quoted line is the YAML parser's. L1.C8-L2.C1 is the stretch it could not read, from line 1, column 8; the mistake is in it. The usual causes are a tab in the indentation, a bracket or quote left open, and an unquoted value holding a colon and a space.

A shortcuts.yaml or font registry that parses can still be refused as one that uses an alias or merge key the build can't read: an alias inside the anchor it names, which never ends, or a merge key (<<:) on something other than a map.

Your metadata file doesn't parse

Every build reads pandoc.yaml, so it has to parse.

Fix the syntax

What belongs in the file is on Book metadata.

Pandoc can't read your metadata

A pandoc.yaml that parses can still be one Pandoc refuses as metadata, most often for a key set twice. The build quotes Pandoc's report: what it found, at its line and column.

Fix what Pandoc names

For a key set twice, keep one of each.

Your shortcuts file doesn't parse

shortcuts.yaml is optional. An empty file, or one holding only comments, defines no shortcuts and builds as if it were absent.

Fix the syntax, or remove the file

How the file is laid out is on Writing your own shortcuts.

Your font registry doesn't parse

fonts/fonts-registry.yaml is optional, and only fonts beyond the built-in set need it.

Fix the syntax, or remove the file

What an entry holds is on Typography & fonts.

Your file holds more than one document

Each file holds one YAML document. A --- above the first key opens it, and ... closes it. Which --- below starts another depends on the file:

  • In pandoc.yaml, any does, one closing the file included: an empty document would reset what came before.
  • In shortcuts.yaml and the font registry, only one with something below it does, a null included. A --- that closes the file, or one with only comments below it, starts none.

Merge the documents into one

Remove each --- line that starts another document, so the keys below it join the document above, and delete any document that is only a null.

A key set twice

A key written twice in one map is refused, since only the last would be kept. shortcuts.yaml and the font registry name it by its path, such as pullquote.interface.size; pandoc.yaml, through Pandoc, by its line and column. Which keys are the same depends on who reads the file:

  • pandoc.yaml is read by Pandoc, so its rule holds. Two keys repeat when their values are equal, as true and True are, or their text is, as 1 and "1" are.
  • shortcuts.yaml and the font registry are read by Keystone. A key is its text as written, a null one included, so ~ and null stay apart. A merge key, <<, repeats only another merge key, and an alias used as a key is the key it names.

Case counts in every file: Title and title are two keys.

Keep one of each

Delete the earlier one, or fold what it held into the one you keep.

The build has no permission to read your file

The build runs as your own user, so it stops at a file your user has no permission to read. The quoted line is the reason the system gave. A fonts/ directory your user can't open hides the font registry instead: the build reads it as absent.

Give your user read access to the file

ls -l shows the file's owner and mode. chmod u+r <file> restores reading on a file you own; sudo chown "$(id -u):$(id -g)" <file> hands back one owned by somebody else.