r-lib / revdepcheck

R package reverse dependency checking
https://revdepcheck.r-lib.org
Other
101 stars 32 forks source link

Error in data.frame(field = names(platform), value = unlist(platform)) : arguments imply differing number of rows: 8, 7 #90

Closed HenrikBengtsson closed 7 years ago

HenrikBengtsson commented 7 years ago

Another, FYI: While rerunning

> revdep_check(bioc = TRUE, num_workers = 16L, timeout = 30*60, quiet = FALSE)

which has already been done previously, where I received yet another error as Issue #88, I get:

$ more Rscript_091254-20170903.o913493 
<U+2500><U+2500> CHECK <U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500
><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+25
00><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+
2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><
U+2500><U+2500><U+2500><U+2500><U+2500> 0 packages <U+2500><U+2500>
OK: 17
BROKEN: 1
Total time: <1 min
<U+2500><U+2500> REPORT <U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+250
0><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2
500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U
+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500>
<U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+2500><U+250
0><U+2500><U+2500><U+2500><U+2500>
Writing summary to 'revdep/README.md'
Error in data.frame(field = names(platform), value = unlist(platform)) : 
  arguments imply differing number of rows: 8, 7
Calls: revdep_check ... cat -> kable -> inherits -> report_platform -> data.frame
11: (function () 
    {
        traceback(2L)
        dump.frames(dumpto = getOption("startup.session.dumpto", 
            "last.dump"), to.file = TRUE)
    })()
10: stop(gettextf("arguments imply differing number of rows: %s", 
        paste(unique(nrows), collapse = ", ")), domain = NA)
9: data.frame(field = names(platform), value = unlist(platform))
8: report_platform()
7: inherits(x, "list")
6: kable(x, row.names = FALSE)
5: cat(kable(x, row.names = FALSE), sep = "\n", file = file)
4: cat_kable(report_platform(), file = file)
3: revdep_report_summary(pkg, file = file.path(root, "README.md"))
2: revdep_report(pkg)
1: revdep_check(bioc = TRUE, num_workers = availableCores(), timeout = 30 * 
       60, quiet = FALSE)

Troubleshooting

Looking at that dumped frame, I find that:

> dump <- get(load("Rtmp5vxJgD.rda"))
> str(dump)
List of 11
 $ revdep_check(bioc = TRUE, num_workers = availableCores(), timeout = 30 * 60   :<environment: 0x5846df8> 
 $ revdep_report(pkg)                                                            :<environment: 0x5847548> 
 $ revdep_report_summary(pkg, file = file.path(root, "README.md"))               :<environment: 0x58474a0> 
 $ cat_kable(report_platform(), file = file)                                     :<environment: 0x58472e0> 
 $ cat(kable(x, row.names = FALSE), sep = "\n", file = file)                    :<environment: 0x58470e8> 
 $ kable(x, row.names = FALSE)                                                   :<environment: 0x5847b48> 
 $ inherits(x, "list")                                                           :<environment: 0x5848308> 
 $ report_platform()                                                             :<environment: 0x5848180> 
 $ data.frame(field = names(platform), value = unlist(platform))                 :<environment: 0x5848068> 
 $ stop(gettextf("arguments imply differing number of rows: %s", paste(unique(   :<environment: 0x584b4d0> 
 $ (function () 
{
    traceback(2)
    dump.frames(dumpto = getOption("startu:<environment: 0x584aee8> 
 - attr(*, "error.message")= chr "Error in data.frame(field = names(platform), value = unlist(platform)) : \n  arguments imply differing number o"| __truncated__
 - attr(*, "class")= chr "dump.frames"
> platform <- dump[["report_platform()"]]$platform
> str(platform)
List of 8
 $ version : chr "R version 3.4.1 (2017-06-30)"
 $ os      : chr(0) 
 $ system  : chr "x86_64, linux-gnu"
 $ ui      : chr "X11"
 $ language: chr "en"
 $ collate : chr "C"
 $ tz      : chr NA
 $ date    : chr "2017-09-03"
 - attr(*, "class")= chr "platform_info"

The problem is that:

> getAnywhere("report_platform")
A single object matching 'report_platform' was found
It was found in the following places
  namespace:revdepcheck
with value

function () 
{
    platform <- platform_info()
    data.frame(field = names(platform), value = unlist(platform))
}
<environment: namespace:revdepcheck>

assumes that platform_info() produce a list of elements all of length one, but platform$os is zero length.

Session details

> library("revdepcheck")
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.6 (Santiago)

Matrix products: default
BLAS: /home/shared/cbc/software_cbc/R/R-3.4.1-20170630/lib64/R/lib/libRblas.so
LAPACK: /home/shared/cbc/software_cbc/R/R-3.4.1-20170630/lib64/R/lib/libRlapack.so

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=en_US.UTF-8    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     

other attached packages:
[1] revdepcheck_1.0.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12         compiler_3.4.1       prettyunits_1.0.2   
 [4] base64enc_0.1-4      remotes_1.1.0        tools_3.4.1         
 [7] progress_1.1.2.9000  digest_0.6.12        bit_1.1-12          
[10] jsonlite_1.5         RSQLite_2.0          memoise_1.1.0       
[13] tibble_1.3.4         debugme_1.0.2        rlang_0.1.2         
[16] whoami_1.1.1         DBI_0.7              yaml_2.1.14         
[19] curl_2.8.1           gmailr_0.7.1         withr_2.0.0         
[22] httr_1.3.1           knitr_1.17           desc_1.1.1          
[25] rappdirs_0.3.1       hms_0.3              rprojroot_1.2       
[28] bit64_0.9-7          glue_1.1.1           crancache_0.0.0.9000
[31] parsedate_1.1.3      R6_2.2.2             processx_2.0.0.1    
[34] rcmdcheck_1.2.1.9002 sessioninfo_1.0.0    callr_1.0.0.9000    
[37] blob_1.1.0           magrittr_1.5         backports_1.1.0     
[40] boxes_0.0.0.9000     clisymbols_1.2.0     assertthat_0.2.0    
[43] cranlike_1.0.1       crayon_1.3.2.9000   
> 

> str(.Platform)
List of 8
 $ OS.type   : chr "unix"
 $ file.sep  : chr "/"
 $ dynlib.ext: chr ".so"
 $ GUI       : chr "X11"
 $ endian    : chr "little"
 $ pkgType   : chr "source"
 $ path.sep  : chr ":"
 $ r_arch    : chr ""
HenrikBengtsson commented 7 years ago

Some more troubleshooting. When I run the following interactively from one of the compute nodes:

> str(sessioninfo::platform_info())
List of 8
 $ version : chr "R version 3.4.1 (2017-06-30)"
 $ os      : chr(0) 
 $ system  : chr "x86_64, linux-gnu"
 $ ui      : chr "X11"
 $ language: chr "en"
 $ collate : chr "C"
 $ tz      : chr NA
 $ date    : chr "2017-09-03"
 - attr(*, "class")= chr "platform_info"
> sessioninfo:::os_name()
character(0)
> utils::sessionInfo()$running
NULL

Looking at the code for utils::sessionInfo():

        uname <- system("uname -a", intern = TRUE)
        os <- sub(" .*", "", uname)
        z$running <- switch(os, Linux = if (file.exists("/etc/os-release")) {
            tmp <- readLines("/etc/os-release")
            t2 <- if (any(startsWith(tmp, "PRETTY_NAME="))) sub("^PRETTY_NAME=", 
                "", grep("^PRETTY_NAME=", tmp, value = TRUE)[1L]) else if (any(startsWith(tmp, 
                "NAME"))) sub("^NAME=", "", grep("^NAME=", tmp, 
                value = TRUE)[1L]) else "Linux (unknown distro)"
            sub("\\"(.*)\\"", "\\\\1", t2)
        } else if (file.exists("/etc/system-release")) {
            readLines("/etc/system-release")
        }, Darwin = {

it looks like for os == "Linux" (which it is on my machine), that it does not guarantee a value, i.e. it returns NULL if both of those if conditions are false (which they are on my machine).

I think revdepcheck:::report_platform() need to be updated to not make assumption about all platform fields being non-empty (alternatively, sessioninfo::os_name() should return NA_character_).

HenrikBengtsson commented 7 years ago

It looks like this should be resolved in the sessioninfo package, because it makes the same assumption when print():ing;

> platform <- sessioninfo: platform_info()
> platform$os <- character(0)
> print(platform)
Error in data.frame(setting = names(x), value = unlist(x), stringsAsFactors = FALSE) : 
  arguments imply differing number of rows: 8, 7

Enter a frame number, or 0 to exit   

1: print(platform)
2: print.platform_info(platform)
3: data.frame(setting = names(x), value = unlist(x), stringsAsFactors = FALSE)
4: stop(gettextf("arguments imply differing number of rows: %s", paste(unique(nr
5: (function () 
{
    utils::recover()
})()
HenrikBengtsson commented 7 years ago

Submitted PR https://github.com/r-lib/sessioninfo/issues/8 to fix this there.

hadley commented 7 years ago

Closing, since resolved in sessioninfo.