RStudio won't run "Run current chunk"

Hello,

I am unable to run any kind of individual chunks in RStudio markdown documents. Once the green run button is pressed, the clock symbol appears, nothing happens and the running indicator on left side of the code just stops at the first line. What could be the cause of this?

This affects the "Run All Chunks Above" button too. Knit-button and all the related ones work, though.

For example, the following markdown document will not run with "Run current chunk" (The \ is for escaping ``` for this forum post):

---
output: html_document
---

```{r, error=TRUE}
print(apple)
1 + 1
\```

My info:

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

RStudio 2024.12.1+563 "Kousa Dogwood" Release (27771613951643d8987af2b2fb0c752081a3a853, 2025-02-02)

Packages:
rmarkdown_2.29
knitr_1.50

Edit: this thread describes the same problem I am having: R markdown chunk will not run

1 Like

Unsurprisingly it runs for me (throwing an error since apple is undefined). Does resetting RStudio's state help?

Thank you for your message @prubin. Unfortunately, resetting Rstudio's internal state and resetting the project folder did not solve these issues for me.

I updated my R to 4.4.3 with fresh package installations, and the Run Current Chunk problem persists.

I notice that RStudio writes my knitr parameters to params, but then hangs immediately on the first line of my markdown document (in my case library(knitr))

Also, I got a message in my console after restarting R session. I do not know if this is relevant:

Registered S3 methods overwritten by 'htmltools':
  method               from         
  print.html           tools:rstudio
  print.shiny.tag      tools:rstudio
  print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'rmarkdown':
  method         from
  print.paged_df

Additionally, I dug this following error message up from rsession-<username>.log found at Help --> Diagnostics --> Show Log Files. <username> is a change made by me. This line was written when I as I was trying to Run Current Chunk.

2025-04-03T07:57:15.400186Z [rsession-<username>] ERROR asio.misc error 2 (End of file) [host: 127.0.0.1:34893, uri: /rpc/console_input, address: 127.0.0.1, port: 34893]; OCCURRED AT void __cdecl rstudio::core::http::AsyncClient<class rstudio_boost::asio::basic_stream_socket<class rstudio_boost::asio::ip::tcp,class rstudio_boost::asio::any_io_executor> >::handleReadStatusLine(const class rstudio_boost::system::error_code &) C:\Users\jenkins\workspace\ide-os-windows\rel-kousa-dogwood\src\cpp\core\include\core/http/AsyncClient.hpp:530; LOGGED FROM: void __cdecl rstudio::session::modules::rmarkdown::notebook::`anonymous-namespace'::NotebookQueue::consoleThreadMain(void) C:\Users\jenkins\workspace\ide-os-windows\rel-kousa-dogwood\src\cpp\session\modules\rmarkdown\NotebookQueue.cpp:530

Do you use Jenkins (open-source process automation software)? That last error message looks like it might be coming from Jenkins. If so, you might want to look for a way to run RStudio without involving Jenkins and see if you can run chunks. (Sorry, I don't use Jenkins -- or Windows, for that matter -- so I can't offer any guidance on this.)

Thank you for your message @prubin . I use the regular Windows release of RStudio with nothing extra. The problem seems to be quite elusive.

Was the Markdown example in your original question the entire document, or did you omit any portions (in particular, headers or library imports)? If it was not the complete document, posting the full contents of a minimal reprex might help.

The Markdown example in my first message is the entire document. My RStudio won't even run that chunk.

Does knitting the entire document in RStudio work? If not, does knitting it in an R session (in a command window, not inside RStudio) work?

Yes, knitting, knitting with parameters and the related things do work. It puzzles me to no end.

For anyone reading, the interim solution seems to be removing proxy settings from .Renviron. For now, comment out http_proxy and https_proxy.

I hope for a speedy conclusion to this bug.

This issue is referenced in:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.