RStudio.Version() not found on knit



I can do this in the RStudio console,

[1] ‘1.1.442’

But, when I put this

RSver <- RStudio.Version()$version

in an Rmd file and click the [Knit] button, I get the following error.

Error in RStudio.Version() : could not find function "RStudio.Version" Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval

I suspect that I just need to load a library, but I can't figure out which one it would be. I tried rstudioapi and rversions.

OS: win7, 64 bit
R: 3.4.4, 64 bit


I don't know exactly how RStudio.Version is doing what it does (and I'm curious to find out!), but you get the same info from rstudioapi::versionInfo()$version, so maybe that's a workaround?


I get a very strange result from that.

Error: RStudio not running the R Markdown tab of RStudio.


That’s... disconcerting. Ceci n’est pas une pipe, indeed! :upside_down_face:

The details of the RStudio IDE-knitr alchemy are pretty murky to me. I’m hoping to learn more from this thread!

This seems like a bit of a forum categorization edge case, but I wonder if this question wouldn’t get more of the right eyeballs in the RStudio IDE category?


I thought about that, but I figure Markdown people have more interest in making this work.

I just joined the community, and this was my very first post. Do people get upset if the same question gets posted in multiple forums?


Welcome! Yeah, posting the same thing to multiple categories is frowned upon — but changing categories to get a better fit is encouraged!

For the RStudio IDE vs R Markdown categories, it's tough to know where things go sometimes because R Markdown is so tightly integrated with the IDE. My loose heuristic so far: would this problem apply to somebody who uses R Markdown but doesn't use the RStudio IDE?


Sounds good. I've only ever used R Markdown in RStudio, so it's hard to imagine that people actually use it on its own. I'll give the thread a day or two in this forum, and if it doesn't get any love, I'll move it.


The functions you are trying to run are intended for use in an interactive RStudio session.

The function rstudioapi::isAvailable() will report if RStudio is running and can be used to conditionally execute code.

If you put rstudioapi::isAvailable() in an Rmd chunk and knit/render it, you will see the return value is FALSE.

What is your actual goal?


I have made an Rmd file to demonstrate a complex issue in R. I want the Rmd file to self-document the computer configuration under which it is executed. I don't have any problem making it report the operating system, the R version, and the versions of all the relevant packages. But, the RStudio version is elusive.


I'm not aware of a way to do this. I think the rationale is like so: the document you are making has no dependency on RStudio itself, but only on the packages used in your code and the rmarkdown/knitr toolchain. I suspect that everything in this thread is still true:

That being said, I can imagine that perhaps your document describes some sort of workflow that involves RStudio and, therefore, it would be nice to programmatically capture version info. I just don't think you can. I suspect you'll need to insert that yourself.



Thank you for the explanation. My report discusses text encoding and the inconsistencies in the way extended characters are rendered or encoded in RStudio and the knitted md and html files. I knit by clicking the [Knit] button, and I don't know if the code behind that button has changed across RStudio versions or if it just depends on the installed version of knitr.

I've implemented a work-around that will suffice if the Rmd file can't query RStudio. I put that chunk of code into a separate .R file, and I source it from the RStudio console. It puts its output into a csv file, which is what I wanted to do anyway. I still have the code chunk in the Rmd file, but I set eval=FALSE.

I'll wait and see if anyone posts a clever way to do this directly in the Rmd file. If not, then my work-around will be good enough.


Ah yes. Encoding and reporting the encoding in knitr are a bit tricky (


I just entered a post linking to my report.


Thanks @ArnoldCross for creating such a thorough study.