From hpages at fhcrc.org  Wed Nov 10 22:13:17 2010
From: hpages at fhcrc.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Wed, 10 Nov 2010 13:13:17 -0800
Subject: [Rd] installed.packages Error: subscript out of bounds
Message-ID: <4CDB0AED.3030606@fhcrc.org>

Hi,

Today we've seen the following problem with the R-2.12 that we use
for our Windows builds:

   > installed.packages()
   Error: subscript out of bounds

After some investigation we discovered that the cause of this failure
was that 1 of the 890 packages currently installed on the machine
(Windows Server 2003 R2) had its DESCRIPTION file empty:

   E:\biocbld\bbs-2.7-bioc\R\library>ls -al DLBCL
   total 1
   drwxr-xr-x+ 1 biocbuild2 root   0 2010-11-08 14:11 .
   drwxr-xr-x+ 1 biocbuild2 root   0 2010-11-10 00:14 ..
   -rwxr-xr-x+ 1 biocbuild2 root   0 2010-11-08 14:11 DESCRIPTION
   -rwxr-xr-x+ 1 biocbuild2 root 357 2010-11-08 14:11 INDEX
   drwxr-xr-x+ 1 biocbuild2 root   0 2010-11-08 14:11 data
   drwxr-xr-x+ 1 biocbuild2 root   0 2010-11-08 14:11 help
   drwxr-xr-x+ 1 biocbuild2 root   0 2010-11-08 14:11 html

Then from R:

   > library(DLBCL)
   Error in library(DLBCL) : there is no package called 'DLBCL'
   > packageDescription("DLBCL")
   Error in packageDescription("DLBCL") :
     DESCRIPTION file of package 'DLBCL' is corrupt
   > installed.packages()
   Error: subscript out of bounds

I have no idea how this DESCRIPTION file ended up empty. I've never
seen this before. Probably a very rare race condition that would be
very hard to reproduce.

Anyway would it be possible to have installed.packages() give
a more informative error message when this happens? That would
make it behave more consistently with packageDescription().

Does something like this sound reasonable?

hpages at latitude:~/svn/R-trunk$ svn diff src/library/utils/R/packages.R
Index: src/library/utils/R/packages.R
===================================================================
--- src/library/utils/R/packages.R	(revision 53546)
+++ src/library/utils/R/packages.R	(working copy)
@@ -453,6 +453,11 @@
                      domain = NA, call. = FALSE)
              next
          }
+        if (NROW(desc) < 1L) {
+            warning(gettextf("file '%s' is corrupt", pkgpath),
+                    domain = NA, call. = FALSE)
+            next
+        }
          desc <- desc[1,]
          Rver <- strsplit(strsplit(desc["Built"], ";")[[1L]][1L],
                           "[ \t]+")[[1L]][2L]

Thanks,

H.

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] installed.packages Error: subscript out of bounds
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=