23

On one computer running R 2.15.2 I have installed packages from a .zip file (these packages happened to be ggplot2 and data.table, but I don't think the specific package is my issue.) Everything works fine. I took these packages to a computer without an internet connection and installed them. This other computer is running R 3.0.1. The packages seemed to install without a problem (using R's "install package(s) from local zip file" option). When I call the packages with the library(), I get the following error:

Error: package '<insert name of newly installed package here>' was build before 3.0.0: please-re-install it

Can anyone explain potential causes for this error to be thrown? Are there particular directories that the .zip packages must be in for a proper install? If R is installed on a separate partition from where the .zip packages were loaded, could this cause the error?

I'm at a loss, any pointers are greatly appreciated. This is a difficult one to reproduce; if you need any other version/system parameters to understand the problem, please don't hesitate to ask.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Docuemada
  • 1,703
  • 2
  • 25
  • 44
  • 3
    The cause of the error is in the error message. You cannot use packages built with R < 3.0.0 in R >= 3.0.0. Solution: rebuild the package(s) using R >= 3.0.0. – Joshua Ulrich Jun 07 '13 at 15:46
  • Crazy error messages being useful! I'll figure out how to do this and get back to the post with the results. – Docuemada Jun 07 '13 at 15:52

6 Answers6

62

I found this solution while look at GitHub ggplot2 issue #796

update.packages(checkBuilt = TRUE, ask = FALSE)

It will update all the packages that need to be reinstalled.

zx8754
  • 52,746
  • 12
  • 114
  • 209
user3003714
  • 754
  • 5
  • 6
5

Running install.packages("codetools") can fix this issue for R 3.0.2, if you have the same problem like me:

installing to /home/user/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘**codetools**’ was built before R 3.0.0: please re-install it
Error : unable to load R code in package ‘Rcpp’
ERROR: lazy loading failed for package ‘Rcpp’
zx8754
  • 52,746
  • 12
  • 114
  • 209
Richard Li
  • 120
  • 2
  • 3
  • 2
    Running that just gives me the same error for every package codetools depends on. Welcome to package dependency hell... Is there no option to recursively rebuild everything? I thought that was a standard feature in every packaging system? – Cerin Feb 28 '14 at 18:54
2

I installed shiny according https://github.com/rstudio/shiny-server/wiki/Ubuntu-step-by-step-install-instructions

and got the same error at the step

sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""

Warning messages:
1: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
 installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
 installation of package ‘httpuv’ had non-zero exit status
3: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
 installation of package ‘shiny’ had non-zero exit status

I tried the answer by Richard Lee by starting R

R

and got the error

Warning in install.packages("shiny") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) n
Error in install.packages("shiny") : unable to install packages

obviously no write permission, so

sudo R

Now I tried again

install.packages("shiny")

and got a number of errors

Error : package ‘codetools’ was built before R 3.0.0: please re-install it
Error : package ‘RJSONIO’ was built before R 3.0.0: please re-install it
Error : package ‘caTools’ was built before R 3.0.0: please re-install it
Error : package ‘bitops’ was built before R 3.0.0: please re-install it
Error : package ‘digest’ was built before R 3.0.0: please re-install it
Error : package ‘xtable’ was built before R 3.0.0: please re-install it

Each time I got an error, I re-installed the requested package

install.packages("codetools")
install.packages("RJSONIO")
etc.

and eventually, I was able to install Rccp, httpuv, and even shiny. Now it works!!

Also see Shiny package installation on R version 3.0.2 "Frisbee Sailing"

Community
  • 1
  • 1
atmelino
  • 2,887
  • 2
  • 20
  • 15
  • i love it when the fix is as simple as following the directions the error message provides...duh! – burkestar Sep 19 '14 at 17:37
  • I dont know if this would help here but `install.packages` comes with a `dependencies = TRUE` options. For example: `install.packages('RMySQL', dependencies = TRUE)` – ErichBSchulz Nov 15 '14 at 08:34
1

I am using rkward on precise

I had a similar error using rkward. Specifically this one:

'lib = "/usr/local/lib/R/site-library"' is not writable

I temporarily changed the permissions for this directory so that rkward could run this from its console:

 update.packages(checkBuilt = TRUE, ask = FALSE)

all to fix this:

Error: package '' was build before 3.0.0: please-re-install it

so that (sigh...) I could fix 'default' configuration for audio on precise. I couldn't use play() etc. in rkward.

That just needed phonon-backend-gtstreamer

zx8754
  • 52,746
  • 12
  • 114
  • 209
0

Here is the work-around that I used:

I installed the latest version of R on an internet-capable computer. I then loaded the my required packages (Packages->install packages->select mirror->select package...

After R is finished installing, it displays a message of where the temporary .zip package is located. I navigated to this location, grabbed the temp package, and burnt it to a cd.

In this way, I could get the newer package build onto a computer without internet access. I would still be interested to know if there is an easy way to rebuild a package downloaded on an early R version to make it compatible with the latest version (without needed an internet connection).

Thanks for pointing me in the right direction @JoshuaUlrich

zx8754
  • 52,746
  • 12
  • 114
  • 209
Docuemada
  • 1,703
  • 2
  • 25
  • 44
  • 1
    Nice work. Can't you just simply grab the packages off of CRAN though? i.e. grab whatever the appropriate binary or source package is from here: http://cran.r-project.org/web/packages/ggplot2/index.html – Chase Jun 07 '13 at 16:24
  • That is *just wrong*. Do `R CMD INSTALL --build foo_1.2.3.tar.gz` which will build you a proper zip archive. – Dirk Eddelbuettel Jun 07 '13 at 16:32
  • As an R newbie, I don't quite understand the above direction, but if you can explain it a bit in an answer, I will give it a try and gladly give you the √ – Docuemada Jun 10 '13 at 14:44
  • @Chase `download.packages` will do that – Dason Nov 18 '13 at 20:08
0

I tried to install swirl on R(v3.1.0) on ubuntu 12.04LTS:

sudo R
install.packages("swirl")

But faced a similar error:

Error : package ‘codetools’ was built before R 3.0.0: please re-install it Error : unable to load R code in package ‘httr’ ERROR: lazy loading failed for package ‘httr’ * removing ‘/usr/local/lib/R/site-library/httr’ ERROR: dependencies ‘testthat’, ‘httr’ are not available for package ‘swirl’ * removing ‘/usr/local/lib/R/site-library/swirl’

Doing following helped me:

install.packages('codetools')
install.packages("swirl")
library("swirl")
swirl()

| Welcome to swirl! Please sign in. If you've been here before, use the same | name as you did then. If you are new, call yourself something unique. What shall I call you?

I hope the same may help fix your installation issue.

VineetChirania
  • 831
  • 1
  • 10
  • 18