Bug 14713 - install.packages() fails with "number of items to replace is not a multiple of replacement length"
install.packages() fails with "number of items to replace is not a multiple o...
Status: CLOSED CONTRIBUTED PACKAGE
Product: R
Classification: Unclassified
Component: Installation
R 2.14.0
x86_64/x64/amd64 (64-bit) Linux
: P5 blocker
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-25 13:54 UTC by Arnaud Installe
Modified: 2014-02-13 04:41 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud Installe 2011-10-25 13:54:03 UTC
Using debian package r-recommended v. 2.14.0~20111021-1, install.packages() fails with the following error:

==========
> install.packages('plyr')
Installing package(s) into ‘/home/arnaud/R/x86_64-pc-linux-gnu-library/2.14’
(as ‘lib’ is unspecified)
Error in .readPkgDesc(lib, fields) :
  number of items to replace is not a multiple of replacement length
==========

I tried this for several packages (R.matlab, plyr, ...) with the same result. Downgrading to r-recommended v. 2.11.1-6 fixed the problem. Also, even though install.packages didn't work, executing the command

    R CMD INSTALL /tmp/plyr-...

from the command line did work for v. 2.14.0~20111021-1.
Not sure if this is specific to the debian package or if this bug is present in the "official" R release as well.
Comment 1 Brian Ripley 2011-10-26 07:49:26 UTC
Others are using 2.14.0 RC without problems: seems to be specific to
Debian (or your setup).
Comment 2 Slawomir Molenda 2011-10-27 22:47:31 UTC
(In reply to comment #0)
> Using debian package r-recommended v. 2.14.0~20111021-1, install.packages()
> fails with the following error:
> 
> ==========
> > install.packages('plyr')
> Installing package(s) into ‘/home/arnaud/R/x86_64-pc-linux-gnu-library/2.14’
> (as ‘lib’ is unspecified)
> Error in .readPkgDesc(lib, fields) :
>   number of items to replace is not a multiple of replacement length
> ==========
> 
> I tried this for several packages (R.matlab, plyr, ...) with the same result.
> Downgrading to r-recommended v. 2.11.1-6 fixed the problem. Also, even though
> install.packages didn't work, executing the command
> 
>     R CMD INSTALL /tmp/plyr-...
> 
> from the command line did work for v. 2.14.0~20111021-1.
> Not sure if this is specific to the debian package or if this bug is present in
> the "official" R release as well.

This bug could be reopened because I have exactly the same problem on arch linux with 64 bit version. I was using compiled package from arch repository (2.13.1) as well as packages compiled by myself (2.13.1, 2.13.2, 2.14-rc).

R versions 2.13.1 and 2.13.2 show me this error:

Error in ret[i, ] <- c(pkgs[i], lib, desc) : 
  number of items to replace is not a multiple of replacement length

All 2.14-rc versions:

Error in .readPkgDesc(lib, fields) :
   number of items to replace is not a multiple of replacement length

It doesn't look specific to Debian. I tried to solve it changing all R_LIBS variables and paths without any result. Also I don't see anything specific in my setup.
Comment 3 Ariel Faigon 2011-11-17 01:20:33 UTC
I had the same issue on Ubuntu 11.10 (debian based) with R 2.14.0 and found the culprit by 'strace'ing the R process and seeing where exactly it failed.

The culprit (in my case) was one bad 'rds' file of the 'sg' package:

     /usr/lib/R/site-library/sg/Meta/package.rds

After reading multiple .rds files, R tries to read this file and that's where, .readPkgDesc(lib, fields) decides to abort and complain about:

     number of items to replace is not a multiple of replacement length

My quick (and admittedly ugly) workaround was:

     sudo chmod 000 /usr/lib/R/site-library/sg

Doing this prevents R from reading the bad '.rds' file from the 'sg' package
and succeeding in the full operation.

Ideally: we should make R resistant to this particular error,
i.e. if a particular '.rds' file looks corrupt or bad, R should print a warning and keep reading the other package descriptions.

Seeing that I have 147 packages installed, from various sources, and only one has a malformed .rds file, this looks like a good approach to solving this problem.  

Anyway, just a thought.  I hope that my work-around can help others.
Comment 4 Ariel Faigon 2011-11-18 22:09:29 UTC
Just a small update: I reported the issue to Soeren Sonnenburg the maintainer of the debian R-CRAN sg (Shogun) package.  Hopefully the root cause can get fixed soon.
Comment 5 Slawomir Molenda 2011-11-20 21:42:10 UTC
(In reply to comment #4)
> Just a small update: I reported the issue to Soeren Sonnenburg the maintainer
> of the debian R-CRAN sg (Shogun) package.  Hopefully the root cause can get
> fixed soon.

Thank you very much Ariel for your comments. About 2 weeks ago I also found about that the problematic package was shogun and its corrupted package.rds.

Steve Lianoglou in one his posts on gmane.comp.ai.machine-learning.shogun showed that it can be quite easily fixed by rewriting package.rds. In my case it was:

$ cd /usr/lib/R/site-library/sg/Meta
$ R
R> x <- readRDS("package.rds")
R> x$DESCRIPTION['Built'] <- paste(R.version$major, R.version$minor, sep=".")
R> saveRDS(x, 'package.rds')

Ideally R should throw more meanigful error, and as you said, be more resistant. Hopefully shogun will be fixed soon.
Comment 6 Brian Ripley 2011-11-21 18:34:43 UTC
On 20/11/2011 20:42, r-bugs@r-project.org wrote:
> https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14713
>
> --- Comment #5 from Slawomir Molenda<slawek.molenda@gmail.com>  2011-11-20 15:42:10 EST ---
> (In reply to comment #4)
>> Just a small update: I reported the issue to Soeren Sonnenburg the maintainer
>> of the debian R-CRAN sg (Shogun) package.  Hopefully the root cause can get
>> fixed soon.
>
> Thank you very much Ariel for your comments. About 2 weeks ago I also found
> about that the problematic package was shogun and its corrupted package.rds.
>
> Steve Lianoglou in one his posts on gmane.comp.ai.machine-learning.shogun
> showed that it can be quite easily fixed by rewriting package.rds. In my case
> it was:
>
> $ cd /usr/lib/R/site-library/sg/Meta
> $ R
> R>  x<- readRDS("package.rds")
> R>  x$DESCRIPTION['Built']<- paste(R.version$major, R.version$minor, sep=".")
> R>  saveRDS(x, 'package.rds')
>
> Ideally R should throw more meanigful error, and as you said, be more
> resistant. Hopefully shogun will be fixed soon.


'Ideally' someone who has the problem and thinks it is up to R to fix it 
will contribute a patch.  Please assign the bug to yourselves.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


Comment 7 Brian Ripley 2011-11-25 10:43:36 UTC
Has anyone filed a Debian bug report, now my initial diagnosis has been confirmed?

The alacrity with which Debian report their bug reports to R should be reciprocated!
Comment 8 Krishna Pingal B 2014-02-12 05:14:07 UTC
Hi, I am new to R and I get an identical error message when I am trying to install ggplot2. I am using R version 3.0.2, platform i686-pc-linux-gnu (32-bit), on ubuntu 12.04.

This is the error message I am getting:

===============
> install.packages('ggplot2')
Installing package into ‘/home/krispin/R/Rpackages’
(as ‘lib’ is unspecified)
Error in .readPkgDesc(lib, fields) : 
  number of items to replace is not a multiple of replacement length
===============

I get the same error when I am trying to install other packages (pylr, glmnet) and also when I try yo install it from source.
Comment 9 Martyn Plummer 2014-02-12 17:31:46 UTC
It's a shame if this is still happening over 2 years later.

I fixed this in R 3.0.2 patched. However, the original sin is that one of the packages you have installed from Debian has corrupt meta data. R 3.0.3 will tell you which one.
Comment 10 Krishna Pingal B 2014-02-12 17:48:35 UTC
(In reply to Martyn Plummer from comment #9)
> It's a shame if this is still happening over 2 years later.
> 
> I fixed this in R 3.0.2 patched. However, the original sin is that one of
> the packages you have installed from Debian has corrupt meta data. R 3.0.3
> will tell you which one.

Thanks for the prompt reply, and BTW do you recommend me to get a newer version of R ?
Comment 11 Krishna Pingal B 2014-02-13 04:41:30 UTC
I solved this problem after following the detailed instructions given here in this mail : https://stat.ethz.ch/pipermail/r-help/2010-November/260696.html

I found out that the problem got resolved after I manually deleted the 'sg' package, interestingly the same one that caused problem 3 years back.