14

When I click "Build & Reload" on the Build tab within RStudio, I get the following error:

==> devtools::document(roclets=c('rd', 'collate', 'namespace'))

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

Exited with status 1.

But when I just enter devtools::document(roclets=c('rd', 'collate', 'namespace')) directly into the console, it works.

In addition, if I uncheck "Build & Reload" under "Automatically roxygenize when running:" in the Build Tools -> Roxygen config, the error disappears.

I've installed the latest devtools with devtools::install_github("hadley/devtools"). I'm using Windows.

If anyone has an suggestions, thank you in advance!

Jeff Erickson
  • 3,783
  • 8
  • 36
  • 43
  • I get the same error. Just curiously, do you have a custom library location or do you just use the default? – PirateGrunt Jun 08 '15 at 14:05
  • @PirateGrunt It's a custom location. – Jeff Erickson Jun 08 '15 at 17:23
  • So is mine. I'm wondering if RStudio is trying to load from the default. – PirateGrunt Jun 08 '15 at 19:31
  • @PirateGrunt Good theory! I might be able to test it this weekend. – Jeff Erickson Jun 09 '15 at 12:03
  • Just encounted this problem - think you get it if you have a custom R library (mine is in ~/R/library), it doesn't seem to be propogated onto the Ctrl+Shift+[D/B] commands. I had to `R --vanilla` (so that my `.libPaths()` was the "default") and install devtools (again) to the default personal library (`~/R/x86_64-pc-linux-gnu-library/3.2`) – mathematical.coffee Sep 07 '15 at 02:13
  • 1
    I had to uncheck "Build & Reload" under "Automatically reoxygenize when running:" in the Build Tools -> Roxygen Configure menu. Installing devtools in the program files/r/3.2.3/lib helped, but it still wanted all the dependencies there as well. Using packrat didn't seem to help either... – Alexander Shenkin Feb 10 '16 at 10:14
  • That works for me @AlexanderShenkin, cheers. Suggest you add it as an answer. – geotheory Oct 30 '16 at 19:04

4 Answers4

3

I had to uncheck "Build & Reload" under "Automatically reoxygenize when running:" in the Build Tools -> Roxygen Configure menu. Installing devtools in the program files/r/3.2.3/lib helped, but it still wanted all the dependencies there as well. Using packrat didn't seem to help either..

  • Yes, this is successfully avoiding the problem, meaning that if I want to reoxygenize it, it crashes anyway. – Garini Oct 23 '18 at 09:56
1

Here's a convenient solution based on mathematical.coffee's comment:

Just run this from Rstudio:

writeLines("install.packages('devtools', repos = 'https://cran.rstudio.com/')", "inst.R")
system("Rscript --vanilla inst.R")
nassimhddd
  • 8,340
  • 1
  • 29
  • 44
  • 3
    That solution didn't work for me. I have devtools and roxygen2 both installed in ~/Library/R/3.2/library and i am still experiencing the same issue above. – lalas Apr 21 '16 at 17:14
0

I encountered this problem multiple times and also with other packages related to devtools (e.g. knitr in the devtools::check()). As it was getting on my nerves, I tried to install devtools in other location of .libPaths(), i.e. in the first standard one (in my case it was /usr/local/lib/R/site-library/). It was telling me that I needed sudo rights. I gave them (as I was utterly annoyed by this) but still, it is needed a large number of dependencies. Therefore, my practical solution was to sudo-copy my "special" R library folder into the standard one. The following code fixed all my problems:

sudo cp -rf /home/myname/R/x86_64-pc-linux-gnu-library/3.4/* /usr/local/lib/R/site-library/

I would like to point out that this is the only effective solution I found. Even so, it lacks elegance and I would definitely prefer if the guys from Rstudio provide a way to link Rstudio to a personally-defined library. It was already my case on startup and I had to add my personal lib to .libPaths() in the file Rprofile.site which is run every time on R startup, but this did not solve the above problem anyhow.

Garini
  • 1,088
  • 16
  • 29
0

I encounter the same issue, what I solve in the latest version of Rstudio is :

Build -> Configure Build Tools -> Build Tools -> Press Configure Button -> Uncheck "Source and binary package builds"

Jim Chen
  • 3,262
  • 3
  • 21
  • 35