Knit button not working in Rstudio

Hi all,

The knit button in my Rstudio has stopped working, throwing the error below:

Error in loadNamespace(name) : there is no package called 'rmarkdown'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

I have followed the suggestions from here, here, here, here, here and here. To summarise, they mostly suggest checking library permissions (no issues) and reinstalling rmarkdown and various other packages (tried with no difference).

Running rmarkdown::render() still works. Does anyone have ideas as to why the knit button doesn't??

Thanks!

Output of sessionInfo() below:

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.3  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6 tools_3.4.3     yaml_2.1.16    
 [8] Rcpp_0.12.15    stringi_1.1.6   rmarkdown_1.9   knitr_1.20      stringr_1.3.0   digest_0.6.15   evaluate_0.10.1

This may be due to a corrupt .Rdata file. Have you tried

  • exiting RStudio
  • blowing away .Rdata in the directory you're trying to knit to
  • re-starting?

Simply re-starting RStudio can cure a number of ills...

Thanks for the suggestion. I haven't tried deleting the .Rdata file, will give that a go. I'm not hopeful because I think I've tried in a clean directory, but will confirm.

I should have also said I have tried completely uninstalling and reinstalling Rstudio, and also deleting the Rstudio-Desktop folder in AppData/Local with no luck.

No good :frowning:
Any other ideas?

Bump... Anyone got ideas?

Because you're bumping, I give you worked for me for a problem remotely similar to yours.
Put this at the beginning of you .Rmd file:

\```{r, echo=FALSE}
knitr::opts_chunk$set(error = TRUE)
\```

I have the exact same issue occurring and have tried all the current above suggestions to no avail. Any further ideas would be greatly appreciated!

Hi Parker,
Turned out my problem was an .Rprofile file which I had forgotten about, and was setting a library location different from my normal one every time I ran knitr (using the button), and hence looked like the button was the problem. It didn't do anything else though, which is why I didn't pick it up earlier.
I only fixed this in the last couple of months, but it's good to have it sorted!

1 Like

Awesome! Since I'm not too familiar with .Rprofile files, is there a set of commands that need to be run to fix the issue? Should I just delete the .Rprofile file?

Yeah, I would suggest do a search for .Rprofile, either manually or via your computer search function and just delete (or rename them). Are you on Windows, Mac or Linux? There are a few default places where it hides - this question might be helpful, or search for more info on Google.
Otherwise, might be best to start a new thread where you can specify all your own details, and I'll jump in and see what I can do to help you.

Cool, I found the .Rprofile and deleted it, and now everything works perfectly! Thanks so much for your help.

Fantastic! Glad that's sorted it out for you!

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.