Error loading tidyverse in Rstudio

I'm seeing an error when trying to load tidyverse in Rstudio. (See attached image.) I don't see the error in base R--I only get it when using Rstudio. I updated the packages and updated Rstudio, but it still didn't work.

Here's another error I receive:

> library(tidyverse)
Error in if (is_string(x)) asNamespace(x) : 
  argument is not interpretable as logical
Error: package or namespace load failed for ‘tidyverse’:
 .onLoad failed in loadNamespace() for 'dplyr', details:
  call: if (is_string(x)) asNamespace(x)
  error: argument is not interpretable as logical

I'm using R version 4.1.2 with Rstudio 2021.09.1:
RStudio 2021.09.1+372 "Ghost Orchid" Release (8b9ced188245155642d024aa3630363df611088a, 2021-11-08) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

After trying to bump this so the topic does not close (which is annoying that a topic can close in a few weeks just because there haven't yet been replies), an Rstudio Sustainer messaged me suggesting that I restart the R session and re-installing tidyverse.

After doing the following:
-updating to the latest stable version of R (4.1.2)
-updating to the latest stable version of Rstudio (2021.09.2+382)
-updating tidyverse and all dependencies

I still get errors when trying to load tidyverse packages. I do not get these errors when loading them in base R--I only get them when running Rstudio. I also don't get the error when restarting the R session in Rstudio. I only get the error in the initial R session load of Rstudio. Is there a way so I don't have to restart the R session every time I load Rstudio?

Here are some of the large variety of errors I've received:

> library(tidyverse)
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
Error: package or namespace load failed for ‘tidyverse’:
 .onLoad failed in loadNamespace() for 'dplyr', details:
  call: options()
  error: Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'
> library(tidyverse)
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
Error: package or namespace load failed for ‘tidyverse’ in is(f, "groupGenericFunction"):
 object 'class2' not found
> library("tibble")
Error: package or namespace load failed for ‘tibble’ in get(name, envir = table):
 argument to 'findVarLoc' is not an environment
> library("tidyverse")
Warning: stack imbalance in 'Recall', 32 then 33
Error: package or namespace load failed for ‘tidyverse’ in is(fdef, "genericFunction"):
 object 'class1Def' not found
Error: package or namespace load failed for ‘tidyverse’ in as.environment(where):
 no item called "methods" on the search list
invalid option "error"
> library("tidyverse")
*** recursive gc invocation
*** recursive gc invocation 
Error: package or namespace load failed for ‘tidyverse’:
 .onAttach failed in attachNamespace() for 'tidyverse', details:
  call: NULL
  error: invalid version specification ‘NULL
> library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in .getClassesFromCache(Class):
 class should be either a character-string name or a class definition
> library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in (function (hash = TRUE, parent = parent.frame(), size = 29L) :
 use of NULL environment is defunct
> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in whichMethodMetaNames(impvars):
 object 'impvars' not found

Here are my package versions:

> 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=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    
system code page: 65001

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.7     purrr_0.3.4     readr_2.1.1     tidyr_1.1.4     tibble_3.1.6   
[8] ggplot2_3.3.5   tidyverse_1.3.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8       cellranger_1.1.0 pillar_1.6.5     compiler_4.1.2   dbplyr_2.1.1     tools_4.1.2     
 [7] jsonlite_1.7.3   lubridate_1.8.0  lifecycle_1.0.1  gtable_0.3.0     pkgconfig_2.0.3  rlang_0.4.12    
[13] reprex_2.0.1     cli_3.1.1        rstudioapi_0.13  DBI_1.1.2        haven_2.4.3      xml2_1.3.3      
[19] withr_2.4.3      httr_1.4.2       fs_1.5.2         generics_0.1.1   vctrs_0.3.8      hms_1.1.1       
[25] grid_4.1.2       tidyselect_1.1.1 glue_1.6.0       R6_2.5.1         fansi_1.0.2      readxl_1.3.1    
[31] tzdb_0.2.0       modelr_0.1.8     magrittr_2.0.1   backports_1.4.1  scales_1.1.1     ellipsis_0.3.2  
[37] rvest_1.0.2      assertthat_0.2.1 colorspace_2.0-2 utf8_1.2.2       stringi_1.7.6    munsell_0.5.0   
[43] broom_0.7.11     crayon_1.4.2

I'm using RStudio 2021.09.2+382 "Ghost Orchid" Release (fc9e217980ee9320126e33cdf334d4f4e105dc4f, 2022-01-04) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

I have the same issue since I updated RStudio a couple of days. I strongly believe this is indeed related to the newer version of RStudio.

The problems started to appear even though I didn't update R or my packages between the moment it was working and the moment it was not.

And updating packages doesn't solve the issue.

RStudio 2021.09.2+382 "Ghost Orchid" Release (fc9e217980ee9320126e33cdf334d4f4e105dc4f, 2022-01-04) for Ubuntu Bionic
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

An interesting note is that the failures are somewhat random.

For example, I could load the tidyverse just now and kept getting the same error over and over:

Error: package or namespace load failed for ‘tidyverse’:
.onLoad failed in loadNamespace() for 'dplyr', details:
call: options()
error: Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'

I restarted the R session and it's now working. I'm assuming there is some issue in the initialization or R.

I logged this as a bug in the GitHub repository for RStudio: https://github.com/rstudio/rstudio/issues/10527. For any folks having a similar issue, I'd encourage you to give it a "thumbs up" at the bottom of the post so it gets attention.

1 Like

@dadrivr Thank you for filing this issue!

A note on upvoting: If there is more discussion in the bug report, upvote the original post.

Thanks!

Ron Blum
Quality Assurance Engineer, RStudio IDE Team

FYI, updating to the just-released version of Rstudio (Prairie Trillium 2022.02.0+443) solved this problem for me: Error loading packages in RStudio · Issue #10527 · rstudio/rstudio · GitHub

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.