klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
829 stars 47 forks source link

Unable to install `box` with `renv=1.0.0` #333

Closed jakubnowicki closed 11 months ago

jakubnowicki commented 11 months ago

Error description

New version of renv (1.0.0) checks if package installed from a binary can be loaded (happens on Linux). box is not able to recognize this situation and throws an error that blocks installation.

Steps to reproduce:

  1. Initialize renv in project:
    remotes::install_version("renv", version = "1.0.0")
    renv::init()
  2. Try to install box :
    renv::install("box", rebuild = TRUE)
    #> # Downloading packages -------------------------------------------------------
    #> 
    #> - Downloading box from RSPM ...                 OK [file is up to date]
    #> 
    #> The following package(s) will be installed:
    #> 
    #> - box [1.1.3]
    #> 
    #> These packages will be installed into "~/tmp_projects/renv_box/renv/library/R-4.3/x86_64-pc-linux-gnu".
    #> 
    #> # Installing packages --------------------------------------------------------
    #> 
    #> - Installing box ...                            FAILED
    #> Error: error testing if 'box' can be loaded [error code 1]
    #> /opt/R/4.3.1/lib/R/bin/R --vanilla -s -f '/tmp/Rtmp0Oh8zr/renv-install-67f1e5c0ac0fa'
    #> ================================================================================
    #> 
    #> NULL
    #> Error: package or namespace load failed for ‘box’:
    #>  .onAttach failed in attachNamespace() for 'box', details:
    #>   call: library(box)
    #>   error: the ‘box’ package is not supposed to be attached!
    #> 
    #> Please consult the user guide at `vignette("box", package = "box")`.
    #> Execution halted

Available workarounds

Setting option --no-test-load:

withr::with_options(
    list(install.opts = "--no-test-load"),
    renv::install("box", rebuild = TRUE)
)
#> # Downloading packages -------------------------------------------------------
#> 
#> - Downloading box from RSPM ...                 OK [file is up to date]
#> 
#> The following package(s) will be installed:
#> 
#> - box [1.1.3]
#> 
#> These packages will be installed into "~/tmp_projects/renv_box/renv/library/R-4.3/x86_64-pc-linux-gnu".
#> 
#> # Installing packages --------------------------------------------------------
#> 
#> - Installing box ...                            OK [installed binary and cached in 0.39s]
#> 
#> Successfully installed 1 package in 0.46 seconds.

R version

R.version
#>                _                           
#> platform       x86_64-pc-linux-gnu         
#> arch           x86_64                      
#> os             linux-gnu                   
#> system         x86_64, linux-gnu           
#> status                                     
#> major          4                           
#> minor          3.1                         
#> year           2023                        
#> month          06                          
#> day            16                          
#> svn rev        84548                       
#> language       R                           
#> version.string R version 4.3.1 (2023-06-16)
#> nickname       Beagle Scouts

‘box’ version

1.1.3

jakubnowicki commented 11 months ago

Cross-referencing issue in renv

klmr commented 11 months ago

Thanks for the report here and on ‘renv’. It appears that the issue has already been fixed. Unfortunately it will probably be a while until the fix will be deployed in a release.

Anyway, a simpler workaround is as follows:

renv::install("box", rebuild = FALSE)