简体   繁体   中英

Rstudio knit pdf in Rstudio loadNamespace(name): there is no package called 'rmarkdown'

I just updated to Rstudio Version 0.98.1074. When I try to use compile notebook with a script or Knit pdf with an .rmd I get

Error in loadNamespace error: there is no package called 'rmarkdown'

yet I can type rmarkdown::render("filename.rmd") and it will render the document. I removed rmarkdown and re-installed with RStudio and it did not help. I've updated all my packages and I'm using R3.1.1.

This is a minor inconvenience since I have a workaround but thought I'd post in case there is a solution that I can't find.

I received almost the exact same error when trying to use Rmarkdown on Windows, within Cygwin:

loadNamespace(name): there is no package called 'rmarkdown'

Everything worked fine within Rstudio, but didn't work when I tried to auto-knit some .Rmd files within Cygwin.

My library path in Rstudio:

.libPaths()
[1] "C:/Users/Gravitas/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.2/library"

My library path as reported in Cygwin, when running C:\\Program Files\\R\\R-3.3.2\\bin\\R.exe :

.libPaths()
[1] "C:/Program Files/R/R-3.3.2/library"

The problem:

  • When Rstudio is run in non-Administrator mode, it cannot write anything into C:/Program Files/R/R-3.3.2/library as this directory is write-protected.
  • Thus, Rstudio writes new packages into the user profile directory, which is freely writable.
  • However, Cygwin was not aware of the user's profile directory, so it could not find all of the newly installed packages.

The solution was to set this environment variable within Cygwin:

export R_LIB=C:/Users/Gravitas/Documents/R/win-library/3.3

Now, the path reported Cygwin is:

.libPaths()
[1] "C:/Users/Gravitas/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.2/library"

And now, I can call bash scripts within Cygwin to auto-knit .Rmd files .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM