问题描述
环境:在 Debian 系统上安装的 R 和 RStudio Server,系统环境为 R 4.4.1、Bioconductor 3.20。
通过 .Rprofile
指定了清华源:
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
安装之后几天安装了一大堆依赖,环境都正常,就没去管它。过了将近半年(2025年5月5日),需要安装一个包时发现无法安装,提示如下错误:
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/bioc/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/bioc/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/annotation/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/annotation/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/experiment/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/experiment/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/workflows/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/workflows/src/contrib/PACKAGES'”
Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.1 (2024-06-14)
Warning message:
package ‘multiMiR’ is not available for this version of R
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/bioc/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/bioc/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/annotation/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/annotation/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/experiment/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/data/experiment/src/contrib/PACKAGES'”
Warning message:
“无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/workflows/src/contrib中读写索引:
无法打开URL'https://mirrors.tuna.tsinghua.edu.cn/bioconductor/packages/3.20/workflows/src/contrib/PACKAGES'”
检查网络都是正常的,但是这些链接通过浏览器打开也是 404 无法访问。
原因分析
根据网上搜索结果得知:
您好,根据 Bioconductor 的安排,在 5 月 15 日,3.18 及此前版本的相关数据已经被归档,并从其同步来源中被移除。为节约镜像站磁盘空间,我们也相应移除了这些文件。该操作是不可逆的,我们无法重新找回在归档中的文件。
另外可以参考:
结论: 镜像站只保留最新版本的 Bioconductor 包,当前已更新到 3.21,对应 R 版本为 4.4.2,因此旧版本 3.20 无法正常访问。
解决方案
方案一:升级 R 和 BiocManager
适用于允许更新系统环境的情况:
更新 R 到最新版本(Debian 下):
sudo apt update && sudo apt upgrade r-base
升级 BiocManager:
install.packages("BiocManager")
但由于服务器上有大量依赖,升级可能引发兼容性问题,所以选择 Plan B。
方案二:更换镜像源(推荐)
西湖大学镜像站 提供了完整的 R & Bioconductor 历史版本支持,包括 R 4.0 以后的所有版本。
修改方法
设置镜像源为西湖大学:
options("repos" = c(CRAN="https://mirrors.westlake.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.westlake.edu.cn/bioconductor")
永久生效方式
在用户根目录下创建或修改 .Rprofile
文件:
- Windows 路径:
C:\Users\<用户名>\.Rprofile
- Linux 路径:
~/.Rprofile
写入以下内容:
options("repos" = c(CRAN="https://mirrors.westlake.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.westlake.edu.cn/bioconductor")
重启 R 或 RStudio 后即可正常使用。