I have a RMD file. I can knit it with knitr from RStudio interface. But when I try to run a separate chunk in console I got errors:
Error in library(bla) : there is no package called bla
where bla
is my homemade package. I haven't installed bla
to my current project. I have packrat initialised and bla
absent from packrat directories. So both ways should not work.
Call .libPaths()
shows me
> .libPaths()
[1] "/home/user/projdir/packrat/lib/x86_64-pc-linux-gnu/3.4.0"
[2] "/home/user/projdir/packrat/lib-ext/x86_64-pc-linux-gnu/3.4.0"
[3] "/home/user/projdir/packrat/lib-R/x86_64-pc-linux-gnu/3.4.0"
I've added .libPaths()
call to my document and got:
[1] "/home/user/Documents/projdir/packrat/lib/x86_64-pc-linux-gnu/3.4.0"
[2] "/home/user/Documents/projdir/packrat/lib-ext/x86_64-pc-linux-gnu/3.4.0"
[3] "/home/user/Documents/projdir/packrat/lib-R/x86_64-pc-linux-gnu/3.4.0"
[4] "/home/user/R/x86_64-pc-linux-gnu-library/3.4"
[5] "/usr/local/lib/R/site-library"
[6] "/usr/lib/R/site-library"
[7] "/usr/lib/R/library"
Why the paths differ? And how can I force knitr to use packages only from packrat?