You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法安装任何R包,报错Error in readRDS(dest) : error reading from connection

Hey there, let's tackle that frustrating Error in readRDS(dest) : error reading from connection issue you're hitting when installing R packages. I've seen this pop up a few times, so here are some tried-and-true fixes you can test out step by step:

常见解决方案
  • 清理损坏的包缓存
    R caches downloaded packages, and corrupted cache files are a common cause of this error. Here's how to fix it:

    1. Run Sys.getenv("R_LIBS_USER") in R to find your personal package library path
    2. Close R completely, then navigate to that path and delete all files with the .rds extension, or clear the entire downloaded_packages folder (that's where cached packages live)
    3. Restart R and try installing the package again
  • 排查网络与镜像源问题
    Unstable internet or problematic CRAN mirrors can lead to incomplete package downloads, which trigger this error:

    • Switch to a more reliable mirror (like the official cloud R project mirror, or a regional one with better connectivity)
    • If you're on a work/school network, try using your phone's hotspot to rule out firewall or proxy interference
    • Download the package's .tar.gz (or .zip for Windows) file manually, then install it locally with install.packages("path/to/your/package/file", repos = NULL, type = "source")
  • 检查权限与R版本兼容性
    Even though you're using stable R 3.4.x versions, permission issues are often the culprit:

    • Launch R as an administrator (right-click R and select "Run as administrator" on Windows; use sudo R in terminal on Mac/Linux) — sometimes regular user accounts don't have write access to the package library
    • Make sure your system has enough free disk space; a full drive can cause file write failures that lead to this error
  • 重置R的包安装配置
    Corrupted configuration settings might be causing the problem. Run this command to reset your CRAN repo to the official default:

    options(repos = c(CRAN="https://cloud.r-project.org/"))
    

    Then try installing the package again.

  • 检查杀毒软件拦截
    Some antivirus tools flag R package files as suspicious, which can corrupt the download or block installation. Try temporarily disabling your antivirus, then attempt to install the package. If it works, add your R package library folder to the antivirus's trusted list to avoid future issues.

内容的提问来源于stack exchange,提问作者Sgt Cheddar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:41:31