I got almost the same error when trying to use Rmarkdown on Windows in Cygwin:
loadNamespace(name): there is no package called 'rmarkdown'
Everything worked fine in Rstudio, but didn't work when I tried to automate some .Rmd files in 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 specified by 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"
Problem:
- When Rstudio starts in a mode other than the administrator, it cannot write anything to
C:/Program Files/R/R-3.3.2/library , since this directory is write-protected. - Thus, Rstudio writes new packages to the user profile directory, which is freely writable.
- However, Cygwin did not know about the user profile directory, so he could not find all the new packages.
The solution was to set this environment variable in Cygwin:
export R_LIB=C:/Users/Gravitas/Documents/R/win-library/3.3
Now the path reported by Cygwin is as follows:
.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 in Cygwin to automatically knit .Rmd files .
source share