Search code examples
rmacospackrat

R packrat init fails with: can't open url and no description file found


After installing packrat and running packrat::init() I get the following error which in my opinion is trying to reach a site which is no longer available, additionally some other errors which I'm not sure are being generated by the first one.

Environment: - OS X 10.10.3 - R version 3.2.0 - packrat 0.4.3 - cran (don't know how to get version for this one)

Fetching sources for packrat (0.4.3) ... OK (CRAN current)
Snapshot written to '/Users/user/RProjects/Data_Specialization/r_programming/packrat/packrat.lock'
Installing packrat (0.4.3) ... Error in download.file(url, destfile, method, mode = "wb", ...) : 
  cannot open URL 'http://cran.rstudio.com/src/contrib/packrat_0.4.3.tgz'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  cannot open: HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘packrat’ failed
Error in hash(descFile) : 
  No DESCRIPTION file at path '/Users/user/RProjects/Data_Specialization/r_programming/packrat/lib/x86_64-apple-darwin13.4.0/3.2.0/packrat/DESCRIPTION'!

From what I've read in this issue its also worth noting that I've got Biocinstaller v1.18.1


Solution

  • Ok, so its a version compatibility issue. We need to install packrat from github like so:

    if (!require("devtools")) install.packages("devtools")
    devtools::install_github("rstudio/packrat")
    

    Then packrat::init() works as expected.

    More information on the repository site.

    Credit goes to @kevinushey for resolving this issue.