Error in readRDS(file) - opened the same file just last week


I first encountered the following error yesterday (Monday) when trying to open File-1, which I had just opened in RStudio 3 days ago (Friday). I did not run any updates or install any new packages between Friday and Monday. File-1 is most definitely not corrupted since I was able to work on the exact same copy on the Friday. I attempted to find a solution by updating my R version from 4.3.2 to 4.3.3 but the error persisted. The error finally went away after I shutdown RStudio, and restarted my laptop - unclear what happened there.

Error in readRDS("RDS Files/File-1.RDS") : 
  ReadItem: unknown type 0, perhaps written by later version of R

However, this error crop up again today (Tuesday) when trying to open a different file (File-2). File-2 was written the same time as File-1 but I have not opened it in a couple of weeks. I am certain it is also not corrupted since I was able to work on it before focusing on File-1 in the past two weeks and have not touched it since. I have tried updating my R again today, though there aren't any new updates since I've only just updated it the day before. I have also tried restarting RStudio and my laptop but it doesn't seem to resolve the error this time, unlike with File-1.

Error in readRDS("RDS Files/File-2.RDS") : 
  ReadItem: unknown type 127, perhaps written by later version of R

I ran infoRDS("RDS Files/File-2.RDS") and had the following info, though unsure what to do with it:

infoRDS('RDS Files/File-2.RDS')
[1] 3

[1] "4.3.2"

[1] "3.5.0"

[1] "xdr"

[1] "UTF-8"

If it helps, this is usually how I save RDS files and have never encountered this error so I don't think it'd be a problem with how I'm saving them?

saveRDS(file2, "RDS Files/File-2.RDS")

I have also included below more details of my setup, and I'd appreciate any help in identifying where the problem lies and how to solve it.. Thank you!

  • RStudio 2023.06.1+524 "Mountain Hydrangea" Release (547dcf861cac0253a8abb52c135e44e02ba407a1, 2023-07-06) for macOS
  • MacBook Pro 2017 (Ventura 13.6.6)

This topic was automatically closed 42 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.