Skip to content

Run all chunks above fails when non R chunks are present #11995

Closed

Description

@thothal

System details

RStudio Edition : Desktop
RStudio Version : 2022.07.0 Build 548
OS Version      :  Win 10
R Version       : 

Steps to reproduce the problem

Consider the following Rmarkdown:

---
title: "Non R Chunks Prevent Run All"
output: html_document
editor_options: 
  chunk_output_type: console
---

```{css css-chunk, echo = FALSE}
.sql {
  background-color: #cdd9ef;
}
```

```{r myconsts}
a <- 1
```

```{sql sql-chunk, connection = DBI::dbConnect(RSQLite::SQLite())}
SELECT 1
```

```{r r-chunk}
a + 1
```

Now press the Run all Chunks above button in the last r chunk:

image

Describe the problem in detail

The first non R chunk (i.e. the CSS chunk) will (naturally) fail with an error in the console, stopping all the other chunks to run. If I remove the CSS chunk, Run all... will trip over the SQL chunk.

image

Describe the behavior you expected

I think it is a natural workflow to run the R code in the console once in a while to some quick checks without the need to re-render the whole document. Any non R chunk prevents me from using the Run all Chunks above button, which is annoying as I have now to run all R chunks manually. I would expect that any non R chunk is excluded from Run all Chunks above by default, or at least a chunk option with which I could manually exclude certain chunks from being considered in the Run all. Another viable solution would be to be able to tell Rstudio to continue on error nevertheless.

N.B. An eval = FALSE chunk option allows me to use the Run all... button, but then, well, the chunk is not evaluated when rendering. Clearly not what I want.

Interestingly enough, if I decide to output inline,, I can at least run the chunks.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on Sep 21, 2022
  2. added
    info needed
    and removed
    new
    on Sep 21, 2022
  3. ronblum commented on Sep 21, 2022

    @ronblum
  4. cderv commented on Sep 22, 2022

    @cderv
    Collaborator

    @ronblum I believe the issue really is that the css chunk should not be run. It does not even have a run button
    image

    So probably Run all Chunk above should skip it. 🤔

  5. self-assigned this
    on Nov 17, 2022
  6. jgutman commented on Nov 17, 2022

    @jgutman
    Contributor

    It appears the CSS chunk does not run with Run All or Run All Chunks Above, so I believe that part of the issue has been resolved. The SQL issue still stands, and interferes with subsequent chunk execution, but the SQL issue is a duplicate of #6769

    This is in version 2022.12.0-preview+330. Closing this issue in preference to #6769, but please comment again if you believe the CSS issue persists -- on my end the CSS does not get executed/evaluated in console mode.

  7. removed
    info needed
    on Nov 30, 2022
  8. DesiQuintans commented on Dec 7, 2022

    @DesiQuintans

    I still get this issue with CSS chunks in RStudio 2022.07.2 Build 576 (newest available) on Windows 11 64-bit.

    I can reproduce it by creating a new RMarkdown doc with the default template (New File > RMarkdown > Okay), inserting this CSS chunk above the setup chunk:

    ```{css, echo=FALSE}
    body {font-family: "Atkinson Hyperlegible" !important; font-size: 13pt !important; }
    pre {font-family: "Hack" !important; font-size: 12pt !important; }
    ```
    

    Enabling "Chunk Output In Console", and then using Run All Chunks Above from the cars R chunk.

    ## Error: unexpected '{' in "body {"
    

    Knitting the Rmd to a HTML page works fine. It's just Run All Chunks Above that does not.

  9. cderv commented on Dec 7, 2022

    @cderv
    Collaborator

    @DesiQuintans it is probably best to open a new issue and link to a close one so that it is triaged correctly.

    @ronblum should we create a new issue from this or is it ok to reopen here if the issue is confirmed by you ?

  10. 12 remaining items

  11. removed their assignment
    on Jan 26, 2023
  12. modified the milestones: Backlog-1, Later on Oct 31, 2023
  13. removed this from the Later milestone on Feb 26, 2024
  14. ronblum commented on Feb 26, 2024

    @ronblum
    Contributor

    Another example, from @GegznaV in issue #14324:

    ```{r}
    ```
    
    ```{css}
    /* Some CSS comment */
    ```
    
    ```{r}
    1 + 2
    ```
    
    ```{r}
    
    ```
    
  15. ronblum commented on Feb 29, 2024

    @ronblum
    Contributor

    Possible solution: in console mode, only execute R chunks

  16. added this to the Cranberry Hibiscus milestone on Feb 29, 2024
  17. victorfeagins commented on Apr 19, 2024

    @victorfeagins

    Any updates on this? For me this is only an issue when output goes to the console instead of inline.

  18. kevinushey commented on Apr 20, 2024

    @kevinushey
    Collaborator

    We're planning to investigate this for the next release.

  19. gadenbuie commented on May 17, 2024

    @gadenbuie
    Member

    Another example, using a custom knitr engine as reported in gadenbuie/epoxy#126

    ---
    output: html_document
    ---
    
    ```{setup}
    library(epoxy)
    ```
    
    ```{epoxy}
    The average speed of the cars was **{mean(cars$speed)} mph.**
    ```
    

    The above document knits correctly, but clicking Run All returns Error: unexpected symbol in "The average"

  20. self-assigned this
    on Sep 10, 2024
  21. ronblum commented on Sep 16, 2024

    @ronblum
    Contributor

    Verified in RStudio Desktop 2024.09.0+372 on Windows 11 using multiple examples from above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions