Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiocManager::valid() not working within reprex::reprex() #4

Closed
PeteHaitch opened this issue Jun 13, 2018 · 11 comments
Closed

BiocManager::valid() not working within reprex::reprex() #4

PeteHaitch opened this issue Jun 13, 2018 · 11 comments

Comments

@PeteHaitch
Copy link
Contributor

Running from a new R session:

> BiocManager::valid()

* sessionInfo()

R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

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

other attached packages:
[1] repete_0.0.0.9011 devtools_1.13.5  

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17           lobstr_0.0.0.9000     
 [3] XVector_0.21.2         magrittr_1.5          
 [5] GenomicRanges_1.33.6   BiocGenerics_0.27.0   
 [7] zlibbioc_1.27.0        IRanges_2.15.14       
 [9] munsell_0.5.0          colorspace_1.3-2      
[11] rlang_0.2.1            stringr_1.3.1         
[13] GenomeInfoDb_1.17.1    plyr_1.8.4            
[15] tools_3.5.0            parallel_3.5.0        
[17] withr_2.1.2            fortunes_1.5-4        
[19] yaml_2.1.19            digest_0.6.15         
[21] GenomeInfoDbData_1.1.0 BiocManager_1.29.45   
[23] pryr_0.1.4             S4Vectors_0.19.12     
[25] bitops_1.0-6           codetools_0.2-15      
[27] RCurl_1.95-4.10        memoise_1.1.0         
[29] stringi_1.2.3          compiler_3.5.0        
[31] scales_0.5.0           stats4_3.5.0          

Bioconductor version '3.8'

  * 0 packages out-of-date
  * 2 packages too new

create a valid installation with

  BiocManager::install(c(
    "hms", "reprex"
  ), update = TRUE, ask = FALSE)

Warning message:
0 packages out-of-date; 2 packages too new 

Running as reprex::reprex(x = BiocManager::valid()):

BiocManager::valid()
#> Error in repos[["CRAN"]]: subscript out of bounds

Created on 2018-06-13 by the reprex package (v0.2.0).

Any ideas? The combo of reprex::reprex() and BiocManager::valid() will be valuable when asking for minimal bug reports.

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jul 6, 2018

Hi Pete, @PeteHaitch
This seems like an issue with the options not being used in the package.
I'm not sure where in the reprex package these options get lost.

options("repos"); BiocManager::valid()
#> $repos
#> [1] "https://cloud.r-project.org" "https://cloud.r-project.org"
#> Error in repos[["CRAN"]]: subscript out of bounds
#> $repos
#> [1] "https://cloud.r-project.org" "https://cloud.r-project.org"

Created on 2018-07-06 by the reprex package (v0.2.0).

@PeteHaitch
Copy link
Contributor Author

Are you saying you think it's a reprex issue rather than a BiocManager issue? If so, I'll report it there.

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jul 9, 2018

Hi Pete, @PeteHaitch
Basically, the package creates a clean environment from which the example code is run
(in order to ensure reproducibility).
This is more of a feature of the package although they should have a way of
setting options as part of the reprex. Perhaps there is a way but I'm not familiar with the package.
@jennybc can surely provide insights.

Regards,
Marcel

@jennybc
Copy link

jennybc commented Jul 9, 2018

To peel the onion a bit more, I wonder if this is a problem with callr? If I follow the above discussion, it is a problem that the return value for options("repos") is unnamed and therefore the attempt to get the "CRAN" element fails. Do I have that right?

reprex "just" prepares a .R file, marked up with some comments relevant to knitr, then calls rmarkdown::render() on it in a fresh R session, using callr::r() (see note).

I'm not sure why the name stripping happens but I can reproduce it with callr alone. FYI callr adds a CRAN repo (https://cloud.r-project.org), although the related code sure looks like it should return a named vector. I'm not sure how the names of "repos" are getting lost.

> getOption("repos")
                       CRAN 
"https://cran.rstudio.com/" 
attr(,"RStudio")
[1] TRUE
> callr::r(function() getOption("repos"))
[1] "https://cran.rstudio.com/"   "https://cloud.r-project.org"
> callr::r_safe(function() getOption("repos"))
[1] "https://cran.rstudio.com/"   "https://cloud.r-project.org"

Note: Technically, reprex::reprex() calls callr::r_safe() because that was necessary with a previous version of callr but the distinction isn't important in the current version.

@jennybc
Copy link

jennybc commented Jul 9, 2018

Hi @gaborcsardi do you have any insight?

@jennybc
Copy link

jennybc commented Jul 9, 2018

Maybe the names on repos are being lost here:

https://github.com/cran/callr/blob/d591dfee954a3a87cdf690c5e4953c4782ec17cb/R/check.R#L27

Small demo:

(x <- c(getOption("repos"), c(CRAN = "whatever")))
#>                       CRAN                       CRAN 
#> "https://cran.rstudio.org"                 "whatever" 
as.character(x)
#> [1] "https://cran.rstudio.org" "whatever"  

@gaborcsardi
Copy link

Indeed!

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jul 9, 2018

Yes, Jenny @jennybc that's right.
The code in BiocManager:::.repositories_base does repos[["CRAN"]] and since callr::r_safe strips the names, we get an error.

@jennybc
Copy link

jennybc commented Jul 10, 2018

This is now fixed in callr FWIW. Thanks for pointing it out.

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jul 10, 2018

Thanks Jenny!

@LiNk-NY LiNk-NY closed this as completed Jul 10, 2018
@PeteHaitch
Copy link
Contributor Author

Can confirm this has fixed the original issue. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants