How to Make Install.Packages Return an Error If an R Package Cannot Be Installed

Rscript install packages: how to make it fail with an error code?

Have you seen install2.r and its --error option?

We use it (and wrote it/added that options) for some of the Dockerfiles in the Rocker Project dedicated to Docker support for R.

R: Error in install.packages : cannot open the connection

Rename the zip file RinSel Software into Rindsel. That's the name specified in the discription file.

Then, you can install the package in R with the command

install.packages("C:/path/to/Rindsel.zip",repos=NULL,type="win.binary")

That works fine... at first (!!!).

Problem with the Rindsel package is. It is quite old. It was build with R 2.13.1. Therefore, if you want to load the library which would be the next step to use the package in R you will get the error:

Problems building package (Error: "package has been build before R-3.0.0")

My suggestion: Contact the authors of the package and ask them if they can either provide the source file that you can build the package by yourself or if they can bundle the Rindsel package with a newer R version.

(Or you could try to hunt down an old R version and see if you can get the thing running with an old R... However, I would not seriously suggest to do that. It would probably result in conflicting dependencies with the other required packages...)

EDIT 15-02-2018: OP asked if one can build an R package with sources that are presumeably the Rindsel source files.

Yes, basically, you could do that. You would have to make a your own description and namespace file and put the source file in the R folder than invoke the command in R to build it....

But it's not neccessary with the script files provided by the link the OP posted.

OP, just run the scripts in R! It's quite easy.

  1. Download the zip-file and extract it on your machine.
  2. Go to that directory. The R command would be

setwd('path/to/your/directory')


  1. Than run the R script, e.g, the KNIndex.r. It's simple:

source('KNIndex.r')

Then the script will run and produce some output / prompts.

Cannot install my created packages

The problem was the special character in my name, á. When I put it in the C:\ directory and ran R CMD build cats and R CMD check cats it passed that error (though there was an error later on with the pdf - I'll see if I can resolve that myself).

I'll try and post this as a bug. Moderately annoying. Should have thought of that test earlier.

R install.packages returns failed to create lock directory

On NFS file systems it is sometimes not obvious what things you have to close.

The best way to avoid this is to use the --no-lock argument on the command line, i.e.:

R CMD INSTALL --no-lock <pkg>

From within R, you can do this from within your command using:

install.packages("Rcpp", dependencies = TRUE, INSTALL_opts = '--no-lock')


Related Topics



Leave a reply



Submit