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

dbplyr itself cannot be loaded #779

Closed
CLRafaelR opened this issue Feb 12, 2022 · 27 comments
Closed

dbplyr itself cannot be loaded #779

CLRafaelR opened this issue Feb 12, 2022 · 27 comments

Comments

@CLRafaelR
Copy link

CLRafaelR commented Feb 12, 2022

I've successfully installed dbplyr but cannot load it using library() due to the error: error: error in contained classes ("character") for class “ident”; class definition removed from ‘dbplyr’. The very same error also causes the installation failure and loading failure of the packages that depend on dbplyr, as a couple of posts (#619, #688, https://community.rstudio.com/t/tidyverse-error-failed-to-load/105345) has already reported for the last few years.

I installed dbplyr 2.1.1 from CRAN and faced the error. I also remove the dbplyr from CRAN, and reinstalled the package by devtools::install_github("tidyverse/dbplyr"); but the error persists. Is there any way to resolve the problem from the user side, or would you please fix this?

Sys.setenv("_R_TRACE_LOADNAMESPACE_" = 4)

Loading dbplyr fails

"dbplyr" %in% installed.packages() # TRUE, which means that the package has already been installed successfully
library(dbplyr)
- loadingdbplyr-- processing imports fordbplyr-- done processing imports fordbplyr-- loading code fordbplyr-- loading code fordbplyr-- registerS3methods fordbplyr-- done registerS3methods fordbplyr-- running .onLoad fordbplyrError in completeSubclasses(classDef2, class1, obj, where) : 
  trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots
Error: package or namespace load failed fordbplyr:
 .onLoad failed in loadNamespace() for 'dbplyr', details:
  call: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
  error: error in contained classes ("character") for classident”; class definition removed fromdbplyr

Loading tidyverse fails, since tidyverse depends on dbplyr

"tidyverse" %in% installed.packages() # TRUE
library(tidyverse)
- loadingtidyverse-- processing imports fortidyverse- loadingdbplyr-- processing imports fordbplyr-- done processing imports fordbplyr-- loading code fordbplyr-- loading code fordbplyr-- registerS3methods fordbplyr-- done registerS3methods fordbplyr-- running .onLoad fordbplyrError in completeSubclasses(classDef2, class1, obj, where) : 
  trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots
Error: package or namespace load failed fortidyverse:
 .onLoad failed in loadNamespace() for 'dbplyr', details:
  call: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
  error: error in contained classes ("character") for classident”; class definition removed fromdbplyr

SessionInfo

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Japanese_Japan.932  LC_CTYPE=Japanese_Japan.932   
[3] LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C                  
[5] LC_TIME=Japanese_Japan.932    

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

other attached packages:
[1] furrr_0.2.3   future_1.23.0

loaded via a namespace (and not attached):
 [1] matrixStats_0.61.0   fs_1.5.2             usethis_2.1.5       
 [4] lubridate_1.8.0      devtools_2.4.3       rprojroot_2.0.2     
 [7] rstan_2.26.6         tools_4.1.2          backports_1.4.1     
[10] utf8_1.2.2           R6_2.5.1             DBI_1.1.2           
[13] colorspace_2.0-2     withr_2.4.3          tidyselect_1.1.1    
[16] gridExtra_2.3        prettyunits_1.1.1    processx_3.5.2      
[19] Brobdingnag_1.2-7    curl_4.3.2           compiler_4.1.2      
[22] cli_3.1.1            desc_1.4.0           scales_1.1.1        
[25] mvtnorm_1.1-3        callr_3.7.0          stringr_1.4.0       
[28] digest_0.6.29        StanHeaders_2.26.6   rmarkdown_2.11      
[31] rethinking_2.21      extraDistr_1.9.1     pkgconfig_2.0.3     
[34] htmltools_0.5.2      parallelly_1.30.0    sessioninfo_1.2.2   
[37] fastmap_1.1.0        rlang_1.0.1          rstudioapi_0.13     
[40] shape_1.4.6          generics_0.1.2       jsonlite_1.7.3      
[43] dplyr_1.0.8          inline_0.3.19        magrittr_2.0.2      
[46] loo_2.4.1            Matrix_1.4-0         Rcpp_1.0.8          
[49] munsell_0.5.0        fansi_1.0.2          lifecycle_1.0.1     
[52] stringi_1.7.6        yaml_2.2.2           MASS_7.3-55         
[55] brio_1.1.3           pkgbuild_1.3.1       grid_4.1.2          
[58] parallel_4.1.2       listenv_0.8.0        crayon_1.4.2        
[61] lattice_0.20-45      knitr_1.37           ps_1.6.0            
[64] pillar_1.7.0         codetools_0.2-18     stats4_4.1.2        
[67] pkgload_1.2.4        glue_1.6.1           evaluate_0.14       
[70] V8_4.1.0             remotes_2.4.2        RcppParallel_5.1.5  
[73] vctrs_0.3.8          testthat_3.1.2       gtable_0.3.0        
[76] purrr_0.3.4          tidyr_1.2.0          assertthat_0.2.1    
[79] cachem_1.0.6         ggplot2_3.3.5        xfun_0.29           
[82] broom_0.7.12         coda_0.19-4          tibble_3.1.6        
[85] memoise_2.0.1        globals_0.14.0       ellipsis_0.3.2      
[88] cmdstanr_0.4.0       bridgesampling_1.1-2
@CLRafaelR
Copy link
Author

UPDATE

I found that dbplyr (and therefore other packages that depend on it, e.g. tidyverse) can be successfully loaded into RGui.exe using library(). Admin mode is not required to successfully run library(dbplyr) using RGui.exe. However, the load of dbplyr and its related packages still fail when I use R from RStudio (RStudio 2021.09.0 Build 341). Running find.package("dbplyr") on both Rgui.exe and RStudio points the same path to the library, "C:/Users/[my username]/Documents/R/win-library/4.1/dbplyr"

@Sz-Tim
Copy link

Sz-Tim commented Feb 22, 2022

I get a similar error when using %dopar% in foreach, but only in parallel (i.e., not with %do%) and only when one of the functions uses a .brmsfit object created with the package brms.

The message printed to the console by foreach is:

Error in { :
task 1 failed - "package or namespace load failed for 'dbplyr':
.onLoad failed in loadNamespace() for 'dbplyr', details:
call: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
error: error in contained classes ("character") for class "ident"; class definition removed from 'dbplyr'"

And if I set the workers to log their output, the error is:

Error in completeSubclasses(classDef2, class1, obj, where) :
trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots

@CLRafaelR
Copy link
Author

CLRafaelR commented Feb 22, 2022

@Sz-Tim

Could you tell us your situation in more detail, since foreach does not seem to depend on dbplyr (see the dependency of foreach here)?

  • How do you load foreach package? Do you use library()?
    • If you use library(), do you always successfully load foreach using library()? (i.e. Does library("foreach") works always successfully?)
    • If library("foreach") works fine, which do you use to execute the command library("foreach"), RStudio or Rgui.exe?
  • Could you tell us the version of the following software/packages you use?
    • R itself
    • RStudio
    • dbplyr
    • foreach
    • rlang (I suspect that dbplyr's load failure started in my environment after updating rlang, though I have no proof of this)

@Sz-Tim
Copy link

Sz-Tim commented Feb 22, 2022

@CLRafaelR

I'm using foreach to run simulations in parallel, and the simulations require tidyverse functions and draw on regressions fitted in brms. I can try to put together a reproducible example, but it will take a little time. The foreach call is:

library(doSNOW); library(foreach)
cl <- makeCluster(12, outfile="temp\\sim_out.txt")
registerDoSNOW(cl)
out.ls <- foreach(i=1:nrow(grid.i), .combine="c", 
                  .packages=c("tidyverse", "brms", "glue", "lubridate") %dopar% {
  ...
}

If I run in series with %do% instead of in parallel with %dopar%, everything works fine. I've tried loading the packages in different orders, explicitly calling them with library() inside the foreach() {...} expression, and loading dplyr directly, but the outcome is always the same.

If I use frequentist regressions (i.e., if I do not use anything from the brms package), there is no error. It's some interaction between brms, dbplyr, and something behind the scenes that foreach does with parallelization. Registering the cluster with doParallel instead of doSNOW has no impact.

This did start about a week ago when I unfortunately updated many packages, which makes it harder to track down exactly which combination is causing the error.


To answer your questions:

  1. I load foreach with library(), and as I said, I've tried loading within foreach using the .packages argument and directly calling library()
    i. I do not get any errors upon loading packages. This is only happening within the parallelized workers.
    ii. This happens within RStudio, both directly from the console and running the script as a local job.
  2. Here is my system info:
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

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

other attached packages:
 [1] doSNOW_1.0.20    snow_0.4-4       iterators_1.0.14 foreach_1.5.2    readxl_1.3.1     brms_2.16.3      Rcpp_1.0.8      
 [8] lme4_1.1-28      Matrix_1.4-0     glue_1.6.1       sf_1.0-6         forcats_0.5.1    stringr_1.4.0    dplyr_1.0.8     
[15] purrr_0.3.4      readr_2.1.2      tidyr_1.2.0      tibble_3.1.6     ggplot2_3.3.5    tidyverse_1.3.1  lubridate_1.8.0 
[22] raster_3.5-15    sp_1.4-6        

loaded via a namespace (and not attached):
  [1] backports_1.4.1      plyr_1.8.6           igraph_1.2.11        splines_4.1.1        crosstalk_1.2.0      usethis_2.1.5       
  [7] rstantools_2.1.1     inline_0.3.19        digest_0.6.29        htmltools_0.5.2      rsconnect_0.8.25     fansi_1.0.2         
 [13] memoise_2.0.1        magrittr_2.0.2       checkmate_2.0.0      remotes_2.4.2        tzdb_0.2.0           modelr_0.1.8        
 [19] RcppParallel_5.1.5   matrixStats_0.61.0   vroom_1.5.7          xts_0.12.1           prettyunits_1.1.1    colorspace_2.0-3    
 [25] rvest_1.0.2          haven_2.4.3          xfun_0.29            rgdal_1.5-28         callr_3.7.0          crayon_1.5.0        
 [31] jsonlite_1.7.3       zoo_1.8-9            gtable_0.3.0         distributional_0.3.0 pkgbuild_1.3.1       rstan_2.21.3        
 [37] abind_1.4-5          scales_1.1.1         mvtnorm_1.1-3        DBI_1.1.2            miniUI_0.1.1.1       xtable_1.8-4        
 [43] units_0.8-0          bit_4.0.4            proxy_0.4-26         StanHeaders_2.21.0-7 stats4_4.1.1         DT_0.20             
 [49] htmlwidgets_1.5.4    httr_1.4.2           threejs_0.3.3        wk_0.6.0             posterior_1.2.0      ellipsis_0.3.2      
 [55] pkgconfig_2.0.3      loo_2.4.1            farver_2.1.0         dbplyr_2.1.1         utf8_1.2.2           tidyselect_1.1.2    
 [61] rlang_1.0.1          reshape2_1.4.4       later_1.3.0          cachem_1.0.6         munsell_0.5.0        cellranger_1.1.0    
 [67] tools_4.1.1          cli_3.1.1            generics_0.1.2       devtools_2.4.3       broom_0.7.12         ggridges_0.5.3      
 [73] evaluate_0.15        fastmap_1.1.0        yaml_2.2.2           processx_3.5.2       knitr_1.37           bit64_4.0.5         
 [79] fs_1.5.2             s2_1.0.7             nlme_3.1-152         projpred_2.0.2       mime_0.12            xml2_1.3.3          
 [85] brio_1.1.3           compiler_4.1.1       bayesplot_1.8.1      shinythemes_1.2.0    rstudioapi_0.13      gamm4_0.2-6         
 [91] testthat_3.1.2       e1071_1.7-9          reprex_2.0.1         stringi_1.7.6        ps_1.6.0             desc_1.4.0          
 [97] Brobdingnag_1.2-7    lattice_0.20-44      classInt_0.4-3       nloptr_2.0.0         markdown_1.1         shinyjs_2.1.0       
[103] tensorA_0.36.2       vctrs_0.3.8          pillar_1.7.0         lifecycle_1.0.1      bridgesampling_1.1-2 httpuv_1.6.5        
[109] R6_2.5.1             promises_1.2.0.1     KernSmooth_2.23-20   gridExtra_2.3        sessioninfo_1.2.2    codetools_0.2-18    
[115] pkgload_1.2.4        boot_1.3-28          colourpicker_1.1.1   MASS_7.3-54          gtools_3.9.2         assertthat_0.2.1    
[121] rprojroot_2.0.2      withr_2.4.3          shinystan_2.5.0      mgcv_1.8-36          parallel_4.1.1       hms_1.1.1           
[127] terra_1.5-21         grid_4.1.1           coda_0.19-4          class_7.3-19         minqa_1.2.4          rmarkdown_2.11      
[133] shiny_1.7.1          base64enc_0.1-3      dygraphs_1.1.1.6   

I'm using RStudio 2021.09.0+351

@padpadpadpad
Copy link

Hi all

I get a similar error when running loading brms in before tidyverse.

library(brms)
library(tidyverse)
Error in completeSubclasses(classDef2, class1, obj, where) : 
  trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots
Error: package or namespace load failed for ‘tidyverse’:
 .onLoad failed in loadNamespace() for 'dbplyr', details:
  call: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
  error: error in contained classes ("character") for class “ident”; class definition removed from ‘dbplyr’

But the other way around works fine.

library(tidyverse)
library(brms)

R version: 4.1.2
RStudio version: RStudio 2022.02.0+443 "Prairie Trillium" Release (9f7969398b90468440a501cf065295d9050bb776, 2022-02-16) for macOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.10 Chrome/69.0.3497.128 Safari/537.36
brms version: 2.16.3
tidyverse version: 1.3.1
dbplyr version: 2.1.1

@Sz-Tim
Copy link

Sz-Tim commented Mar 9, 2022

Reversing the order doesn't stop the error for me, but I did find a sequence that works.

Everything runs successfully if I start the function (that is being parallelized) with:

library(brms); library(Matrix); library(tidyverse)

I'm currently using parallel::parLapply() instead of foreach.

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

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

other attached packages:
 [1] forcats_0.5.1   stringr_1.4.0   dplyr_1.0.8     purrr_0.3.4     readr_2.1.2     tidyr_1.2.0     tibble_3.1.6   
 [8] ggplot2_3.3.5   tidyverse_1.3.1 Matrix_1.4-0    brms_2.16.3     Rcpp_1.0.8     

loaded via a namespace (and not attached):
  [1] minqa_1.2.4          colorspace_2.0-3     ellipsis_0.3.2       ggridges_0.5.3       rsconnect_0.8.25    
  [6] markdown_1.1         fs_1.5.2             base64enc_0.1-3      rstudioapi_0.13      farver_2.1.0        
 [11] rstan_2.21.3         DT_0.20              fansi_1.0.2          mvtnorm_1.1-3        lubridate_1.8.0     
 [16] xml2_1.3.3           bridgesampling_1.1-2 codetools_0.2-18     splines_4.1.1        shinythemes_1.2.0   
 [21] bayesplot_1.8.1      projpred_2.0.2       jsonlite_1.7.3       nloptr_2.0.0         broom_0.7.12        
 [26] dbplyr_2.1.1         shiny_1.7.1          compiler_4.1.1       httr_1.4.2           backports_1.4.1     
 [31] assertthat_0.2.1     fastmap_1.1.0        cli_3.1.1            later_1.3.0          htmltools_0.5.2     
 [36] prettyunits_1.1.1    tools_4.1.1          igraph_1.2.11        coda_0.19-4          gtable_0.3.0        
 [41] glue_1.6.1           reshape2_1.4.4       posterior_1.2.0      cellranger_1.1.0     vctrs_0.3.8         
 [46] nlme_3.1-152         crosstalk_1.2.0      tensorA_0.36.2       ps_1.6.0             rvest_1.0.2         
 [51] lme4_1.1-28          mime_0.12            miniUI_0.1.1.1       lifecycle_1.0.1      gtools_3.9.2        
 [56] MASS_7.3-54          zoo_1.8-9            scales_1.1.1         colourpicker_1.1.1   hms_1.1.1           
 [61] promises_1.2.0.1     Brobdingnag_1.2-7    parallel_4.1.1       inline_0.3.19        shinystan_2.5.0     
 [66] gamm4_0.2-6          gridExtra_2.3        loo_2.4.1            StanHeaders_2.21.0-7 stringi_1.7.6       
 [71] dygraphs_1.1.1.6     checkmate_2.0.0      boot_1.3-28          pkgbuild_1.3.1       rlang_1.0.1         
 [76] pkgconfig_2.0.3      matrixStats_0.61.0   distributional_0.3.0 lattice_0.20-44      rstantools_2.1.1    
 [81] htmlwidgets_1.5.4    processx_3.5.2       tidyselect_1.1.2     plyr_1.8.6           magrittr_2.0.2      
 [86] R6_2.5.1             generics_0.1.2       DBI_1.1.2            withr_2.4.3          pillar_1.7.0        
 [91] haven_2.4.3          mgcv_1.8-36          xts_0.12.1           abind_1.4-5          modelr_0.1.8        
 [96] crayon_1.5.0         utf8_1.2.2           tzdb_0.2.0           grid_4.1.1           readxl_1.3.1        
[101] callr_3.7.0          threejs_0.3.3        reprex_2.0.1         digest_0.6.29        xtable_1.8-4        
[106] httpuv_1.6.5         RcppParallel_5.1.5   stats4_4.1.1         munsell_0.5.0        shinyjs_2.1.0    

@isaactpetersen
Copy link

isaactpetersen commented Mar 13, 2022

I receive the error as well. I'm on a Linux cluster and can't update R to a more recent version.

I receive the error when trying to load {tidyverse}:

> library("tidyverse")
Error in completeSubclasses(classDef2, class1, obj, where) : 
  trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots
Error: package or namespace load failed for ‘tidyverse’:
 .onLoad failed in loadNamespace() for 'dbplyr', details:
  call: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
  error: error in contained classes ("character") for class “ident”; class definition removed from ‘dbplyr’
Execution halted

Here are the versions of packages I have installed:

tidyverse: 1.3.1
dbplyr: 2.1.1
Matrix: 1.4-0
renv: 0.15.4

Here's my sessionInfo():

R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /opt/ssoft/apps/2021.1/linux-centos7-skylake_avx512/gcc-9.3.0/intel-mkl-2020.4.304-glgoamq/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.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 datasets  utils     methods   base     

loaded via a namespace (and not attached):
  [1] nlme_3.1-155         matrixStats_0.61.0   xts_0.12.1          
  [4] lubridate_1.8.0      threejs_0.3.3        rstan_2.21.3        
  [7] tensorA_0.36.2       tools_4.0.5          backports_1.4.1     
 [10] utf8_1.2.2           R6_2.5.1             DT_0.21             
 [13] DBI_1.1.2            colorspace_2.0-3     tidyselect_1.1.2    
 [16] gridExtra_2.3        prettyunits_1.1.1    processx_3.5.2      
 [19] Brobdingnag_1.2-7    emmeans_1.7.2        compiler_4.0.5      
 [22] cli_3.2.0            shinyjs_2.1.0        sandwich_3.0-1      
 [25] colourpicker_1.1.1   posterior_1.2.0      scales_1.1.1        
 [28] dygraphs_1.1.1.6     checkmate_2.0.0      brms_2.16.3         
 [31] mvtnorm_1.1-3        ggridges_0.5.3       callr_3.7.0         
 [34] stringr_1.4.0        digest_0.6.29        StanHeaders_2.21.0-7
 [37] minqa_1.2.4          base64enc_0.1-3      pkgconfig_2.0.3     
 [40] htmltools_0.5.2      fastmap_1.1.0        htmlwidgets_1.5.4   
 [43] rlang_1.0.1          shiny_1.7.1          farver_2.1.0        
 [46] generics_0.1.2       zoo_1.8-9            crosstalk_1.2.0     
 [49] gtools_3.9.2         dplyr_1.0.8          distributional_0.3.0
 [52] inline_0.3.19        magrittr_2.0.2       loo_2.4.1           
 [55] bayesplot_1.8.1      Matrix_1.4-0         Rcpp_1.0.8          
 [58] munsell_0.5.0        fansi_1.0.2          abind_1.4-5         
 [61] lifecycle_1.0.1      stringi_1.7.6        multcomp_1.4-18     
 [64] MASS_7.3-55          pkgbuild_1.3.1       plyr_1.8.6          
 [67] grid_4.0.5           parallel_4.0.5       promises_1.2.0.1    
 [70] crayon_1.5.0         miniUI_0.1.1.1       lattice_0.20-45     
 [73] splines_4.0.5        ps_1.6.0             pillar_1.7.0        
 [76] igraph_1.2.11        boot_1.3-28          markdown_1.1        
 [79] estimability_1.3     shinystan_2.6.0      reshape2_1.4.4      
 [82] codetools_0.2-18     stats4_4.0.5         rstantools_2.1.1    
 [85] glue_1.6.2           renv_0.15.4          RcppParallel_5.1.5  
 [88] vctrs_0.3.8          httpuv_1.6.5         gtable_0.3.0        
 [91] purrr_0.3.4          assertthat_0.2.1     ggplot2_3.3.5       
 [94] mime_0.12            xtable_1.8-4         coda_0.19-4         
 [97] later_1.3.0          survival_3.3-0       tibble_3.1.6        
[100] shinythemes_1.2.0    TH.data_1.1-0        ellipsis_0.3.2      
[103] bridgesampling_1.1-2

@netique
Copy link

netique commented Mar 14, 2022

Interestingly enough, when I library(dbplyr) and then library(tidyverse), it works well. Another point is that in RStudio, when I load tidyverse and get the ominous error, typing dbplyr:: immediately throws

Error in completeSubclasses(classDef2, class1, obj, where) : 
  trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots

Also, failed tidyverse load does not put any tidyverse package on search path.

But when I create a completely new project, everything works.

EDIT: when a clear the history, it works even in the project that it previously failed in...
EDIT2: The issue seems to lie in previously loading brms. Any tidyverse or dbplyr library call then results in the error.

session_info.txt

Note the DLL MD5 mismatch for RcppParallel.
EDIT: I have reinstalled RcppParallel from source, no DLL mismatch is present, but the issue persist.

@netique
Copy link

netique commented Mar 14, 2022

FYI, there is full loadNamespace trace (using _R_TRACE_LOADNAMESPACE_ = 4):

out.txt

@proshano

This comment was marked as outdated.

@netique
Copy link

netique commented Mar 20, 2022

@proshano Note the rstan, bridgesampler and others, such as emmeans loaded via namespace. The issue have to be caused by some method registration conflict about Stan-related packages and tidyverse/dbplyr.

@netique
Copy link

netique commented Mar 25, 2022

Don`t want to be annoying, but is anyone actively solving this? It seems like a big deal not to be able to load a package...

@mgirlich
Copy link
Collaborator

I now managed to reproduce the issue.

library(bridgesampling)
library(dbplyr)

I tracked the issue down to methods::completeSubclasses():

for (i in seq_along(contains)) {
      obji <- contains[[i]]
      cli <- contains[[i]]@superClass
      cliDef <- getClassDef(cli, package = packageSlot(obji))
      subcl <- cliDef@subclasses[[class2]]
      if (is.null(subcl)) {
        exti <- extends(classDef2, cliDef, fullInfo = TRUE)
        if (identical(exti, FALSE) || (is(exti, "SClassExtension") && 
          exti@distance > 1L && classDef@className == 
          exti@by)) 
          setIs(class2, cli, extensionObject = obji, 
            doComplete = FALSE, where = where)
      }
    }

The 4th element of contains is the class index of the Matrix package

cli
#> [1] "index"
#> attr(,"package")
#> [1] "Matrix"

The line getClassDef(cli, package = packageSlot(obji)) returns

  • NULL if bridgesampling is loaded but Matrix is not.
  • and returns
Extended class definition ( "ClassUnionRepresentation" )
Virtual Class "index" [package "Matrix"]
.. .

if neither bridgesampling nor Matrix are loaded or both are loaded.

@mgirlich
Copy link
Collaborator

mgirlich commented Mar 28, 2022

This can be further simplified to creating a package with

#'@importFrom Brobdingnag brob
#'@importFrom Matrix nearPD
f <- function(x) {}

And then I found that Brobdingnag defines index as a Union

setClassUnion("index", members =  c("numeric", "logical", "character"))

which seems to cause the issue.

The Matrix package has the same definition for index but it also exports the Class in the Namespace

Edit: Exporting actually does not help...

@hadley Can you help here?

@hadley
Copy link
Member

hadley commented Mar 28, 2022

@mgirlich what's the connection to dbplyr here? I assume it must be something to do with the setOldClass() calls on .onLoad():

methods::setOldClass(c("ident_q", "ident", "character"), ident_q())
methods::setOldClass(c("ident", "character"), ident())
methods::setOldClass(c("sql", "character"), sql())

But there's must be something else going on because this works fine:

library(methods)

setClassUnion("index", c("numeric", "logical", "character"))
setOldClass(c("ident", "character"), dbplyr::ident())

Created on 2022-03-28 by the reprex package (v2.0.1)

Unfortunately this sort of problem is very hard to debug as its likely to be a bug either in S4 or in the way that bridgesampling, dbplyr, or one of their dependencies is using it.

@mgirlich
Copy link
Collaborator

I think it is a bug in S4 and/or an issue of bridgesampling.

My picture what happens is:

  • dbplyr calls setOldClass(c("ident", "character"), dbplyr::ident())
  • Somewhere deep down this calls methods::completeSubclasses()

There it iterates over the S4 classes that have "character" in their class definition. One of these classes is index. Now

  • if nothing or Matrix is loaded: the index class is found as part of Matrix
  • if bridgesampling is loaded but Matrix not: the index class is found as part of bridgesampling

Then it tries to find class definition of index but can't find it in the 2nd case.
The issue seems to vanish (at least for me) if bridgesampling does not define index itself but rather re-exports it from Matrix. This should be the easiest fix. Do you think this makes sense?

@hadley
Copy link
Member

hadley commented Mar 28, 2022

How can "if bridgesampling is loaded but Matrix not" happen? bridgesampling imports Matrix in the DESCRIPTION and specficially imports matrix::nearPD() in the NAMESPACE. Did you mean "attached" rather than loaded? i.e. the problem is that something deep in completeSubclasses() is relying on the search path?

And why is the briddgesampling the root cause? It doesn't seem to define any S4 classes of its own? .... Oh it's just the order in which it loads namespaces. So an even simpler reprex is:

requireNamespace("Brobdingnag")
#> Loading required namespace: Brobdingnag
requireNamespace("Matrix")
#> Loading required namespace: Matrix
requireNamespace("dbplyr")
#> Loading required namespace: dbplyr
#> Error in completeSubclasses(classDef2, class1, obj, where) : 
#>   trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots

Created on 2022-03-28 by the reprex package (v2.0.1)

@hadley
Copy link
Member

hadley commented Mar 28, 2022

Even simpler:

requireNamespace("Brobdingnag")
#> Loading required namespace: Brobdingnag
requireNamespace("Matrix")
#> Loading required namespace: Matrix
methods::setOldClass(c("ident", "character"))
#> Error in completeSubclasses(classDef2, class1, obj, where) : 
#>   trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots
#> Error in setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where): error in contained classes ("character") for class "ident"; class definition removed from '.GlobalEnv'

Created on 2022-03-28 by the reprex package (v2.0.1)

So it seems almost certain that the problem lies in Brobdingnag

@hadley
Copy link
Member

hadley commented Mar 28, 2022

(Oh I think you just accidentally wrote bridgesampling above, when you meant Brobdingnag)
...
(Oh yeah, and my reprex does the same thing your minimal package reprex does)

@mgirlich
Copy link
Collaborator

The problem is fixed in the dev version of Brobdingnag. Install it with devtools::install_github("RobinHankin/Brobdingnag") and you should have no more issues loading dbplyr.

@hadley
Copy link
Member

hadley commented Mar 30, 2022

I pinged Michael Lawrence about this and he also pushed a fix to R-devel: wch/r-source@3d97199

@kjayhan
Copy link

kjayhan commented Sep 22, 2022

devtools::install_github("RobinHankin/Brobdingnag") keeps throwing the same error for me:

Error: Failed to install 'Brobdingnag' from GitHub:
HTTP error 401.
Bad credentials

Rate limit remaining: 53/60
Rate limit reset at: 2022-09-22 07:16:23 UTC

Couldn't solve this. Any help would be appreciated.

Edit: after reinstalling devtools, it worked for me (I think that's what made it work, at least).

@martina-starc
Copy link

martina-starc commented Sep 30, 2022

I get the error: error in contained classes ("character") for class “ident”; class definition removed from ‘dbplyr’ when I try to install Brobdingnag with devtools::install_github("RobinHankin/Brobdingnag"). 😬

Edit: I could install it after I reinstalled Matrix.

@nfancy
Copy link

nfancy commented Apr 3, 2023

I am still having this issue with dbplyr and installing the devtools::install_github("RobinHankin/Brobdingnag"). The trace is attached. Any pointer is appreciated. Thanks.

> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.1 (2022-06-23)
 os       Ubuntu 20.04.3 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       Etc/UTC
 date     2023-04-03
 rstudio  2022.07.1+554 Spotted Wakerobin (server)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────────────────────────
 ! package              * version   date (UTC) lib source
   annotate               1.76.0    2022-11-01 [1] Bioconductor
   AnnotationDbi          1.60.2    2023-03-10 [1] Bioconductor
   Biobase                2.58.0    2022-11-01 [1] Bioconductor
   BiocFileCache          2.6.1     2023-02-17 [1] Bioconductor
   BiocGenerics           0.44.0    2022-11-01 [1] Bioconductor
   BiocManager            1.30.19   2022-10-25 [1] CRAN (R 4.2.1)
   BiocParallel           1.32.3    2022-11-23 [1] Bioconductor
   biomaRt                2.54.1    2023-03-20 [1] Bioconductor
   Biostrings             2.66.0    2022-11-01 [1] Bioconductor
   bit                    4.0.5     2022-11-15 [1] CRAN (R 4.2.1)
   bit64                  4.0.5     2020-08-30 [1] CRAN (R 4.1.3)
   bitops                 1.0-7     2021-04-24 [1] CRAN (R 4.1.3)
   blob                   1.2.4     2023-03-17 [1] CRAN (R 4.2.1)
   cachem                 1.0.7     2023-02-24 [1] CRAN (R 4.2.1)
   circlize               0.4.15    2022-05-10 [1] CRAN (R 4.2.1)
   ClassDiscovery         3.4.0     2021-07-16 [1] CRAN (R 4.2.1)
   cli                    3.6.1     2023-03-23 [1] CRAN (R 4.2.1)
   clue                   0.3-63    2022-11-19 [1] CRAN (R 4.2.1)
   cluster                2.1.4     2022-08-22 [1] CRAN (R 4.2.1)
   codetools              0.2-18    2020-11-04 [4] CRAN (R 4.0.3)
   colorspace             2.1-0     2023-01-23 [1] CRAN (R 4.2.1)
   ComplexHeatmap         2.14.0    2022-11-01 [1] Bioconductor
   crayon                 1.5.2     2022-09-29 [1] CRAN (R 4.2.1)
   curl                   5.0.0     2023-01-12 [1] CRAN (R 4.2.1)
   DBI                    1.1.3     2022-06-18 [1] CRAN (R 4.1.3)
   dbplyr                 2.3.2     2023-03-21 [1] CRAN (R 4.2.1)
   DelayedArray           0.24.0    2022-11-01 [1] Bioconductor
   DESeq2                 1.38.1    2022-11-15 [1] Bioconductor
   digest                 0.6.31    2022-12-11 [1] CRAN (R 4.2.1)
   doParallel             1.0.17    2022-02-07 [1] CRAN (R 4.2.1)
   dplyr                  1.1.1     2023-03-22 [1] CRAN (R 4.2.1)
 V EWCE                   0.99.3    2022-11-01 [1] Bioconductor (on disk 1.6.0)
   fansi                  1.0.4     2023-01-22 [1] CRAN (R 4.2.1)
   fastmap                1.1.1     2023-02-24 [1] CRAN (R 4.2.1)
   filelock               1.0.2     2018-10-05 [1] CRAN (R 4.2.1)
   foreach                1.5.2     2022-02-02 [1] CRAN (R 4.2.1)
   future                 1.32.0    2023-03-07 [1] CRAN (R 4.2.1)
   geneplotter            1.76.0    2022-11-01 [1] Bioconductor
   generics               0.1.3     2022-07-05 [1] CRAN (R 4.1.3)
   GenomeInfoDb           1.34.9    2023-02-02 [1] Bioconductor
   GenomeInfoDbData       1.2.9     2022-11-28 [1] Bioconductor
   GenomicRanges          1.50.1    2022-11-06 [1] Bioconductor
   GetoptLong             1.0.5     2020-12-15 [1] CRAN (R 4.2.1)
   ggdendro               0.1.23    2022-02-16 [1] CRAN (R 4.2.1)
   ggplot2                3.4.1     2023-02-10 [1] CRAN (R 4.2.1)
   GlobalOptions          0.1.2     2020-06-10 [1] CRAN (R 4.2.1)
   globals                0.16.2    2022-11-21 [1] CRAN (R 4.2.1)
   glue                   1.6.2     2022-02-24 [1] CRAN (R 4.1.3)
   gridExtra              2.3       2017-09-09 [1] CRAN (R 4.2.1)
   gtable                 0.3.3     2023-03-21 [1] CRAN (R 4.2.1)
   HGNChelper             0.8.1     2019-10-24 [1] CRAN (R 4.2.1)
   hms                    1.1.3     2023-03-21 [1] CRAN (R 4.2.1)
   httr                   1.4.5     2023-02-24 [1] CRAN (R 4.2.1)
   igraph                 1.3.5     2022-09-22 [1] CRAN (R 4.2.1)
   IRanges                2.32.0    2022-11-01 [1] Bioconductor
   iterators              1.0.14    2022-02-05 [1] CRAN (R 4.2.1)
   KEGGREST               1.38.0    2022-11-01 [1] Bioconductor
   lattice                0.20-45   2021-09-22 [4] CRAN (R 4.1.1)
   lifecycle              1.0.3     2022-10-07 [1] CRAN (R 4.2.1)
   limma                  3.54.2    2023-02-28 [1] Bioconductor
   listenv                0.9.0     2022-12-16 [1] CRAN (R 4.2.1)
   locfit                 1.5-9.6   2022-07-11 [1] CRAN (R 4.2.1)
   magrittr               2.0.3     2022-03-30 [1] CRAN (R 4.1.3)
   MASS                   7.3-58.1  2022-08-03 [1] CRAN (R 4.2.1)
   Matrix                 1.5-3     2022-11-11 [1] CRAN (R 4.2.1)
   MatrixGenerics         1.10.0    2022-11-01 [1] Bioconductor
   matrixStats            0.63.0    2022-11-18 [1] CRAN (R 4.2.1)
   mclust                 6.0.0     2022-10-31 [1] CRAN (R 4.2.1)
   memoise                2.0.1     2021-11-26 [1] CRAN (R 4.1.3)
   munsell                0.5.0     2018-06-12 [1] CRAN (R 4.1.3)
   oompaBase              3.2.9     2019-08-24 [1] CRAN (R 4.2.1)
   oompaData              3.1.2     2022-05-03 [1] CRAN (R 4.2.1)
   parallelly             1.35.0    2023-03-23 [1] CRAN (R 4.2.1)
   pillar                 1.9.0     2023-03-22 [1] CRAN (R 4.2.1)
   pkgconfig              2.0.3     2019-09-22 [1] CRAN (R 4.1.3)
   plyr                   1.8.8     2022-11-11 [1] CRAN (R 4.2.1)
   png                    0.1-8     2022-11-29 [1] CRAN (R 4.2.1)
   prettyunits            1.1.1     2020-01-24 [1] CRAN (R 4.1.3)
   progress               1.2.2     2019-05-16 [1] CRAN (R 4.1.3)
   R6                     2.5.1     2021-08-19 [1] CRAN (R 4.1.3)
   rappdirs               0.3.3     2021-01-31 [1] CRAN (R 4.1.3)
   RColorBrewer           1.1-3     2022-04-03 [1] CRAN (R 4.1.3)
   Rcpp                   1.0.10    2023-01-22 [1] CRAN (R 4.2.1)
   RCurl                  1.98-1.12 2023-03-27 [1] CRAN (R 4.2.1)
   reshape2               1.4.4     2020-04-09 [1] CRAN (R 4.2.1)
   rjson                  0.2.21    2022-01-09 [1] CRAN (R 4.2.1)
   rlang                  1.1.0     2023-03-14 [1] CRAN (R 4.2.1)
   RNOmni                 1.0.1     2022-08-15 [1] CRAN (R 4.2.1)
   RSQLite                2.3.0     2023-02-17 [1] CRAN (R 4.2.1)
   rstudioapi             0.14      2022-08-22 [1] CRAN (R 4.2.1)
   S4Vectors              0.36.2    2023-02-26 [1] Bioconductor
   scales                 1.2.1     2022-08-20 [1] CRAN (R 4.2.1)
   sessioninfo            1.2.2     2021-12-06 [1] CRAN (R 4.1.3)
   shape                  1.4.6     2021-05-19 [1] CRAN (R 4.2.1)
   stringi                1.7.12    2023-01-11 [1] CRAN (R 4.2.1)
   stringr                1.5.0     2022-12-02 [1] CRAN (R 4.2.1)
   SummarizedExperiment   1.28.0    2022-11-01 [1] Bioconductor
   tibble                 3.2.1     2023-03-20 [1] CRAN (R 4.2.1)
   tidyselect             1.2.0     2022-10-10 [1] CRAN (R 4.2.1)
   utf8                   1.2.3     2023-01-31 [1] CRAN (R 4.2.1)
   vctrs                  0.6.1     2023-03-22 [1] CRAN (R 4.2.1)
   XML                    3.99-0.14 2023-03-19 [1] CRAN (R 4.2.1)
   xml2                   1.3.3     2021-11-30 [1] CRAN (R 4.1.3)
   xtable                 1.8-4     2019-04-21 [1] CRAN (R 4.1.3)
   XVector                0.38.0    2022-11-01 [1] Bioconductor
   zlibbioc               1.44.0    2022-11-01 [1] Bioconductor

 [1] /home/nfancy/R/x86_64-pc-linux-gnu-library/4.2
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

 V ── Loaded and on-disk version mismatch.

trace_out.txt

@CuteGold0407
Copy link

I encountered the same problem when I libraried another packages "proActiv", but then I might accidentally library the dbplyr successfulliy. Although I dont know exactly how they are going, here's my solution:
1.remove.packages("rlang")
2.install.packages("rlang")
restarting Rstudio
3.install.packages("rlang")
4.library(dbplyr) first
5.library(proActiv) then
I dont know whether this way can be applied here, just sharing^_^

@lanjlgle
Copy link

For me, all the solutions above cannot work. But I found the error only occured when I open a rstudio project which had been created before, nor a newly created rstudio project.

Then, I add code "library(dbplyr)" in file "Rprofile.site", the error never occur any more.

@amateur-boy
Copy link

@lanjlgle Bro,but,you are a real hero

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