quarto-dev / quarto-dev/quarto-cli

[lint] Inform users when setup chunk is present in unexpected location

Open
#13,358 0 comments 1 reaction 1 assignee View on GitHub

@cscheid is already working on this.

Since Sep 9, 2025.

enhancement lint
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

When interactively executing chunks within the RStudio IDE, RStudio will also look for and execute a chunk with the label "setup". The intention here is to better facilitate interactive analysis, where the setup chunk might be responsible for loading required packages, loading datasets, and other similar operations. (For motivation -- this session state might be lost after a session restart, or in other scenarios, so we wanted a light-weight way to get the user back to the "ready" state.)

However, RStudio doesn't currently verify that the setup chunk is the first chunk in the document, and so this can lead to an unexpected user experience wherein the chunk called setup, regardless where it lives in the document, gets executed before any other chunk in the document is run.

This seems like a potential candidate for the Quarto linter? That is, it might be worth verifying -- If there is an R chunk called "setup", it should be the first chunk in the document.

See also:

https://r4ds.had.co.nz/r-markdown.html#:~:text=There%20is%20one%20chunk%20name%20that%20imbues%20special%20behaviour%3A%20setup.%20When%20you%E2%80%99re%20in%20a%20notebook%20mode%2C%20the%20chunk%20named%20setup%20will%20be%20run%20automatically%20once%2C%20before%20any%20other%20code%20is%20run

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.