Where is knitr used by RStudio?

rmarkdown
rstudio
knitr

#1

To run Rmd chunks, RStudio seems to use knitr's code internally in tools:rstudio environment. Curiously, it won't be updated even when I install the development version of knitr... Anyone knows when and where RStudio captures the knitr's code?

Some contexts: I tried to fix this issue, but the warning won't go away even when I install the patched version of knitr.

Here's steps to reproduce:

  1. Install the patched branch.
devtools::install_github("yutannihilation/knitr@test-notebook-sql-chunk")
  1. Close and relaunch RStudio to make sure to have a fresh R session.
  2. Open a new R Markdown file, and copy and paste this Rmd codes.
  3. Run chunks by ▷ ("Run Current Chunk") buttons on the top right of the chunks.

Then, I think you'll see a warning which is supposed to be fixed at my branch...


#2

@yutannihilation

this is what you need :slight_smile:

```{sql , connection = conn, output.var= result}
select * from test
```

```{r}
head(result)
```

Another Tips is that the short-cut can be configured in RStudio, like ctrl + alt + S, means insert a SQL chunk.


#3

Thanks, but I think it's not what I need; I want to fix RStudio, not to fix the Rmd codes, which is supposed to be executed without warnings...


#4

RStudio uses its own internal routine when running SQL chunks interactively, as defined here:

so unfortunately, updating knitr alone won't fix the issue as seen within RStudio. We'd need to patch our own routine as well.


#5

Thanks, that's what I wanted to know! I didn't expect the knitr's source code is copied into the RStudio's source code...


#6

(Disclaimer: I'm not an expert of OSS licenses.)

I'm happy to send a PR to fix this, but I feel a bit uneasy that there seems no credit to the original author of knitr in RStudio's source code. Are there any agreement between Yihui and RStudio to grant these lines of codes? Or, am I missing something?

Fortunately, knitr's license is GPL (GPLv2/GPLv3) and RStudio's license is AGPLv3, and GPLv3 and AGPLv3 can be considered compatible, so I believe there would be no actual problem. To be clear, I don't have a strong opinion on this and just want to avoid confusion.


#7

In this case, members of RStudio were authors of (at least, the initial) implementation of the SQL engine:

I imagine we inlined this code into RStudio to help prevent any possible issues that could occur if knitr were to update and break some of the assumptions made in our internal notebook implementation.


#8

Ah, thanks for the context. It makes sense.

to help prevent any possible issues that could occur if knitr were to update and break some of the assumptions

I understand the motivation and feel it's valid. Yet, I hope someday we'll find some nice way to keep the assumptions without inlining :slight_smile:


#9

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