8

I recently updated to R 3.1.3 and I am building a package using RStudio and packrat. I am trying to re-build my package using RStudio's in built "Build and Reload" tool, but it won't work. I keep receiving the following error:

Updating standaRd documentation
Loading standaRd
Error in (function (dep_name, dep_ver = NA, dep_compare = NA)  : 
  Dependency package ggplot2 not available.
Calls: suppressPackageStartupMessages ... <Anonymous> -> load_all -> load_depends -> mapply -> <Anonymous>
Execution halted

Exited with status 1.

The thing is, I have ggplot2 installed in all places including my local libraries and my packrat libraries for this project for both R 3.1.2 and R 3.1.3. I have tried loading them in to no avail.

Also, using devtools::build() and devtools::document() both work, so I am assuming that this is an RStudio issue?

I am using RStudio Version 0.99.235. I also cannot see any of my documentation for my package and it doesn't appear to be in my packrat library.

I have since uninstalled R 3.1.3 and reverted back to R 3.1.2 and I am still getting the same issue.

These are my dependencies:

Depends:
    R (>= 3.1.2),
    ggplot2 (>= 1.0.0),
    grid
TylerH
  • 20,799
  • 66
  • 75
  • 101
nathaneastwood
  • 3,664
  • 24
  • 41
  • What if you move ggplot to Imports instead? Putting packages in Depends is considered a doubtful practice. – tonytonov Mar 13 '15 at 13:39
  • Can you build from the command line? – Carl Witthoft Mar 13 '15 at 13:39
  • 2
    I still get the same issue if I put `ggplot2` in the Imports field. I have always had the package built this way and it was only when I upgraded R that I started having the issues. I'm not sure how to build form the command line but `devtools::build()` works fine... – nathaneastwood Mar 13 '15 at 13:42

2 Answers2

0

packrat doesn't seem to be great at handling this, and I always fail to find the documentation I'm looking for. I managed to get it to install packages for the new version, but I don't know exactly which steps were crucial and in which order.

packrat.lock contained a reference to the old RVersion. This can be updated by hand, but packrat::snapshot() also did it for me. I tried packrat::restore() after this and didn't see a new directory for the R version in PROJECT/packrat/lib/ARCH/. I tried restarting and reloading RStudio, the project and packrat a few times and eventually got it to install packages in there. One more project reload and the packages could be seen.

I think there is a "blessed" command sequence for this and it was easier for me in the past.

Sam Brightman
  • 2,831
  • 4
  • 36
  • 38
0

It may worth to use the renv package instead of packrat.

From https://rstudio.github.io/renv/articles/renv.html

The goal is for renv to be a robust, stable replacement for the Packrat package, with fewer surprises and better default behaviors.

greenjune
  • 11
  • 1
  • That is one option, yes. `renv` effectively replaced `packrat` many years ago now. Docker is also another option. – nathaneastwood Oct 28 '22 at 12:47
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33047506) – ncraig Nov 01 '22 at 22:04