Skip to content

More helpful error messages when Quarto chunk options are mis-specified #2434

@cscheid

Description

@cscheid

Discussed in #2433

Originally posted by AmeliaMN September 13, 2022
I posted this on the RStudio community as well, but figured out it should actually be here.

If you mess up when specifying your Quarto chunk options and use = instead of : in one of your code chunks (cough, former RMarkdown users), you will get a pretty impenetrable (to me) error about YAML. For example:

---
title: "Untitled"
format: pdf
editor: visual
---

```{r}
#| label: math
#| echo = false
2 * 2
```

Gives the error

processing file: test.qmd
Error in yaml::yaml.load(meta, handlers = list(expr = parse_only)) : 
  Scanner error: while scanning a simple key at line 2, column 1 could not find expected ':' at line 3, column 1
Calls: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Execution halted

I spent way too much time looking for errors in my header YAML, forgetting that those #| comments are basically YAML now, too. One of the problems is the line 3 part. I was looking in the third line of my Quarto document!

Not sure if it would be possible, but it would be awesome to have an error message that said something like Scanner error: while scanning the options in chunk 1, ...

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingyaml-validationIssues with YAML validation and autocompletion in quarto

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions