Package unavailable in package build after R update using packrat
Asked Answered
S

2

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
Shortcircuit answered 13/3, 2015 at 11:38 Comment(3)
What if you move ggplot to Imports instead? Putting packages in Depends is considered a doubtful practice.Cloche
Can you build from the command line?Haddix
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...Shortcircuit
M
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.

Maggee answered 11/5, 2018 at 12:52 Comment(0)
M
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.

Marden answered 27/10, 2022 at 20:48 Comment(2)
That is one option, yes. renv effectively replaced packrat many years ago now. Docker is also another option.Shortcircuit
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 ReviewGiraffe

© 2022 - 2024 — McMap. All rights reserved.