REditorSupport / sublime-ide-r

R-IDE: Make Sublime Text a perfect IDE for R
MIT License
112 stars 7 forks source link

Problem Rendering R Markdown File #42

Closed eteitelbaum closed 4 years ago

eteitelbaum commented 4 years ago

Hi Randy,

When I hit "Render R Markdown" in R-IDE I get this message:

> rmarkdown::render('Polanyi.Rmd', encoding = 'UTF-8')
Error in loadNamespace(name) : there is no package called 'rmarkdown'
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
[Finished in 0.2s]

I can knit the document in RStudio so I know that rmarkdown is there and I can also render it using R-IDE on another machine with the exact same setup as this one (both are running Windows 10 and RStudio Desktop is selected in SendCode).

Thanks for any clues you might have.

-Emmanuel

randy3k commented 4 years ago

It is most likely rmarkdown is installed in a folder that cannot be discovered by R-IDE. Try running .libPaths() in RStudio and compare it with

Screen Shot 2020-05-23 at 2 12 09 PM
eteitelbaum commented 4 years ago

OK, yes, R-IDE sees the common library but is missing the personal library. How do I add the path for the personal library so that R-IDE can see it?

randy3k commented 4 years ago

Does the directory Sys.getenv(“R_LIBS_USER”) exist ?

eteitelbaum commented 4 years ago

Yes, I get "C:/Users/emman/RLibrary/4.0" when I type Sys.getenv("R_LIBS_USER"), whereas the common library is "C:/Program Files/R/R-4.0.0/library". R-IDE is seeing the common library but not the user library, where rmarkdown and languageserver are both installed. I think I changed the path of the user library at one point because somehow it had been installed in "OneDrive."

randy3k commented 4 years ago

I think I changed the path of the user library at one point because somehow it had been installed in "OneDrive."

That explains. The default user library is something like~/R/win-library/4.0

eteitelbaum commented 4 years ago

OK thanks. I take it that the quickest way to resolve this is to change the path of the user library back to the default and reinstall my R packages. In other words, there is no setting I can change to get R-IDE to recognize the new path?

randy3k commented 4 years ago

It is not an R-IDE specific issue. It was caused by incorrect configuration of R_LIBS_USER. You might either specify your user directory by using .libPath() or specifying the environmental variable R_LIBS_USER.

See R documentation: https://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html for more details.

eteitelbaum commented 4 years ago

Thank you. I set the R_LIBS_USER variable to value of the new file path and everything is working now. There is a discussion of how to do it on stackoverflow in case other people find it useful: https://stackoverflow.com/questions/15170399/change-r-default-library-path-using-libpaths-in-rprofile-site-fails-to-work