[R] Problem on running update

Martin Morgan mtmorgan at fhcrc.org
Mon Nov 22 03:55:20 CET 2010


On 11/21/2010 05:21 PM, Stephen Liu wrote:
> Hi Martin,
> 
> Thanks for your advice.  
> 
> This is my first time hunting for cause of error on R.

Hi Stephen --

read the help pages ?browser, ?recover *before* trying to use the
commands ...

> ?browser
> ?recover

> 
> Steps performed as follows;
> 
>> Sys.glob(file.path(.libPaths()[1], "*", "DESCRIPTION"))
>  [1] "C:\\Users\\satimis\\Documents/R/win-library/2.12/Ecdat/DESCRIPTION"       
>  [2] "C:\\Users\\satimis\\Documents/R/win-library/2.12/RColorBrewer/DESCRIPTION"

[snip]
> [36] "C:\\Users\\satimis\\Documents/R/win-library/2.12/tweedie/DESCRIPTION"     
>>

> 
>> traceback()
> 5: .readPkgDesc(lib, fields)
> 4: installed.packages(lib.loc = lib.loc)
> 3: NROW(instPkgs)
> 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, 
>        available = available, checkBuilt = checkBuilt)
> 1: update.packages(repos = "http://cran.r-project.org")
> 
> Enter a frame number, or 0 to exit   

This says that the error occurred in the .readPkgDesc function; likely
one of your package 'DESCRIPTION' files is corrupt. Take a look at the
source of .readPkgDesc:

> utils:::.readPkgDesc
function (lib, fields, pkgs = list.files(lib))
{
    ret <- matrix(NA_character_, length(pkgs), 2L + length(fields))
    for (i in seq_along(pkgs)) {
        pkgpath <- file.path(lib, pkgs[i])
        if (file.access(pkgpath, 5L))
            next
        pkgpath <- file.path(pkgpath, "DESCRIPTION")
        if (file.access(pkgpath, 4L))
            next
        desc <- tryCatch(read.dcf(pkgpath, fields = fields),
            error = identity)
        if (inherits(desc, "error") || NROW(desc) < 1L) {
            warning(gettextf("read.dcf() error on file '%s'",
                pkgpath), domain = NA, call. = FALSE)
            next
        }
        desc <- desc[1L, ]
        Rver <- strsplit(strsplit(desc["Built"], ";")[[1L]][1L],
            "[ \t]+")[[1L]][2L]
        desc["Built"] <- Rver
        ret[i, ] <- c(sub("_.*", "", pkgs[i]), lib, desc)
    }
    ret[!is.na(ret[, 1L]), ]
}
<environment: namespace:utils>

you'll end up somewhere in the middle of this code. The variable 'pkgs'
will contain a vector of packages, and you'll likely be processing the
i'th package. So provoke the error

> options(error=recover)
>  update.packages(repos="http://cran.r-project.org")

and when the bug occurs

> 1: update.packages(repos = "http://cran.r-project.org")
> 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, a
> 3: NROW(instPkgs)
> 4: installed.packages(lib.loc = lib.loc)
> 5: .readPkgDesc(lib, fields)
> 
> Selection: 

indicate that you'd like to enter the 5th 'Selection'

> Selection: 5

You should see something like

Browse[1]>

you are 'inside' .readPkgDesc, so you can look around a little, e.g.,

Browse[1]> pkgs
Browse[1]> length(pkgs)
Browse[1]> i
Browse[1]> pkgs[i]

and with a little luck pkgs[i] will be the problem. It'll be located in
the directory

Browse[1]> lib

it would be helpful to look at the content of the DESCRIPTION file, to
understand what is wrong

Browse[1]> readLines(pkgpath)

If 'i' is 1 or length(pkgs) then it might pay to look around some more
-- these occur at the start and end of the loop in .readPkgDesc, so you
might be having problems in one of the surrounding lines.

To fix this, one might quit the browser

Browser[1]> Q

and quit recover

> Selection: 0

and reset how errors are handled

> options(error=NULL)

and use remove.packages() (see ?remove.packages) to remove the problem
package. Alternatively, you might find it necessary to use your
operating system to manually remove the directory in which the
DESCRIPTION file was found.

Include the output of

> sessionInfo()

to make sure you're using a recent version of R. Here's mine:

> sessionInfo()
R version 2.12.0 Patched (2010-11-21 r53647)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.12.0

Martin


> starting httpd help server ... done
> 
> Browser[1] ?recover
> 
> Looked at them and wondered what to do next?
> 
> 
> B.R.
> Stephen L
> 
> 
> 
> ----- Original Message ----
> From: Martin Morgan <mtmorgan at fhcrc.org>
> To: Stephen Liu <satimis at yahoo.com>
> Cc: r-help at r-project.org
> Sent: Mon, November 22, 2010 1:30:29 AM
> Subject: Re: [R] Problem on running update
> 
> On 11/21/2010 03:12 AM, Stephen Liu wrote:
>> Hi Martin,
>>
>> Thanks for your advice.
>>
>> Ran following code on R-2.12.0 32bit as admin
>>
>>> for(lib in .libPaths()) {
>> + descs <- Sys.glob(file.path(lib, "*", "DESCRIPTION"))
>> + sizes <- file.info(descs)$size
>> + names(sizes) <- descs
>> + print(sizes[sizes < 100])
>> + }
>> named numeric(0)
>> named numeric(0)
>>
>> Where are the above files?
> 
> If your  problem was as a regular user, then run the above code as
> regular user not admin.
> 
> Not sure what 'the above files' are that you are looking for; the 'named
> numeric(0)' says that no packages have DESCRIPTION files with size <
> 100; the loop looked in all directories in
> 
>   .libPaths()
> 
> for a subdirectory with file DESCRIPTION; you can find these by for instance
> 
>   Sys.glob(file.path(.libPaths()[1], "*", "DESCRIPTION"))
> 
> Your next step is to identify where the error is occurring; you might try
> 
>   update.packages(repos="http://cran.r-project.org")
> 
> and when the error occurs use
> 
>   traceback()
> 
> to understand the functions that are being called at the time of the
> error; the output of traceback() will be helpful to the list, even if
> not useful to you. The next step is likely to try to identify more
> precisely where the problem is, e.g.,
> 
>    options(error=recover)
>    update.packages(repos="http://cran.r-project.org")
> 
> and then following the instructions on ?recover and ?browser to more
> precisely identify the problem. Use options(error=NULL) to turn off
> recovery when done.
> 
> Martin
> 
>>
>>
>> B.R.
>> Stephen L
>>
>>
>>
>>
>> ----- Original Message ----
>> From: Martin Morgan <mtmorgan at fhcrc.org>
>> To: Stephen Liu <satimis at yahoo.com>
>> Cc: r-help at r-project.org
>> Sent: Sun, November 21, 2010 2:10:52 PM
>> Subject: Re: [R] Problem on running update
>>
>> On 11/20/2010 08:56 PM, Stephen Liu wrote:
>>> Hi folks,
>>>
>>> Win 7 64bit
>>> R 2.12.)
>>>
>>> Today on running:
>>>
>>>> update.packages()
>>> Error: subscript out of bounds
>>>
>>> Unable to proceed.  I have been googling around and couldn't discover the 
>>> cause.  Pls help.  TIA
>>
>> Hi Stephen -- maybe
>>
>> https://stat.ethz.ch/pipermail/r-help/2010-November/259912.html
>>
>> Martin
>>
>>>
>>>
>>> B.R.
>>> Stephen L
>>>
>>>
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> 
> 


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the R-help mailing list