So I've struck a really weird bug. I have an RMarkdown document which loads tidyverse that I have been working on for many months. Last week it started giving me an error when I load the tidyverse library, either as a separate call in the console, or as part of the cell with the library call, or when I knit the document. The error message is:
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’
Weirdly, this does not occur when I load tidyverse in a different R session (in either the console or another Rmd document), even if it is exactly the same RMarkdown text and code (i.e., copy pasted). It seems to be associated with opening the problematic Rmd, and this makes my R session weird.
Note that I do not save my R session, R history, previous source documents or in anyway restore .Rdata when opening RStudio, and there is no .Rdata file in the folder or any of it's subdirectories.
I thought RMarkdown documents (.Rmd) were essentially text files, but this behaviour makes me think there is some shenanigans going on behind the scenes where it is trying to load dbplyr (which is not part of the default tidyverse library), and that is causing the error. However loading dbplyr in a new document (and R session) works fine.
This problem is easy to solve as I can just copy paste the text from the problematic document into a new one, but it bugs me that my mental model of how .Rmd works is failing me here. Can anyone help me understand?
Ta,
Rich
R version 4.1.3 (2022-03-10) -- "One Push-Up"
RStudio 2022.02.0 Build 443
tidyverse 1.3.1
rmarkdown 2.14
dbplyr 2.1.1