Installing R Packages Error in Readrds(File):Error Reading from Connection

Error in readRDS(nsInfoFilePath) : error reading from connection

I encountered the same error while using ggplot2, even with very simple data and graph.

I traced the readRDS function with the following code :

trace(readRDS, quote(print(ls.str())))

which after running the ggplot code returned something like :

Tracing readRDS(metapath) on entry
file : chr "/home/username/R/x86_64-pc-linux-gnu-library/4.1/farver/Meta/package.rds"
refhook : NULL

I reinstalled the farver package, the error disappeared and I was finally able to plot the graph I wanted.

This package (and the package.rds file) was probably not installed correctly.

I found a similar issue and the tracing command here.

readRDS(file) in R

These are suggestions I have come across:

  1. Delete your .Rhistory and .RData files in the directory in which you are running R.
  2. Run update.packages()
  3. Try and detect "bad files" in your library directories. You can do this in R

    # List the library paths
    # The issue is likely to be in the first directory
    paths = .libPaths()

    ## Try and detect bad files
    list.files(paths,
    pattern = "^00LOCK*|*\\.rds$|*\\.RDS$",
    full.names = TRUE)

    ## List files of size 0
    l = list.files(paths, full.names = TRUE)
    l[sapply(l, file.size) == 0]

    Delete any files/directories highlighted. You could use file.remove() if you really wanted to.

  4. Delete the directory in which you have stored your downloaded packages.

Only solution 3 worked for me.

Ref:

  • R-sig-Debian mailing list
  • Option 3 was a combination of answers provided by different people over the last few years, including Chunxiao Xu, Larry Hunsicker and Frank Harrell

Installing Bioconductor packages error -- Error in readRDS(dest) : error reading from connection

I faced the same problem for BioConductor packages. I found a working solution here.

install.packages("devtools")    
devtools::install_github("Bioconductor/BiocManager", ref="ghost-binary-repo")

Error installing packages in RStudio: error reading from connection

This certainly is an issue with your connection:the proxies you are using and repositories configured in your RStudio. I was getting the same error when I was connected to US VPN from India.I disconnected VPN and restarted RStudio and it worked like a charm!



Related Topics



Leave a reply



Submit