要说多少遍非零状态的R包安装失败根本就不是看它本身

前些天我们在《生信技能树》和《生信菜鸟团》同步宣传了:Linux公益课2021的视频,并且提供了一个免费的服务器是,是60万的超高配置服务器 ( 96线程512G内存48T硬盘的5台)的其中一台。但是很多人上完这个公益课,还想蹭我们的服务器(因为承诺是免费一个月),所以要求我安装一些R包。

我就翻出来了我以前的代码,给新服务器安装R包!

首先使用 sudo R 命令来打开R(因为我就是管理员,所以可以sudo),然后输入下面的R代码:


bioPackages <-c(
 "shiny", "devtools", "ggplot2", "pheatmap", "ggpubr", "ggstatsplot", "airway", "DESeq2", "edgeR", "limma", "clusterProfiler"
 )

local({
 r <- getOption( "repos" );
 r[ "CRAN" ] <- "https://mirrors.tuna.tsinghua.edu.cn/CRAN/";
 options( repos = r )
 BioC <- getOption( "BioC_mirror" );
 BioC[ "BioC_mirror" ] <- "https://mirrors.ustc.edu.cn/bioc/";
 options( BioC_mirror = BioC )
})

# source( "https://bioconductor.org/biocLite.R" )
# 这行代码已经过时,新版本的R语言3.6.0已经不再使用
if (!requireNamespace("BiocManager", quietly = TRUE))
 install.packages("BiocManager")
lapply( bioPackages,
 function( bioPackage ){
 if( !require( bioPackage, character.only = T ) ){
 CRANpackages <- available.packages()
 if( bioPackage %in% rownames( CRANpackages) ){
 install.packages( bioPackage )
 }else{
 BiocManager::install( bioPackage, suppressUpdates = FALSE, ask = FALSE)
 }
 }
 }
)

library(shiny)
library(devtools)
library(ggplot2)
library(pheatmap)
library(ggpubr)
library(ggstatsplot)
library(airway)
library(DESeq2)
library(edgeR)
library(limma)
library(clusterProfiler)
# library之后均没有报错

一般来说都不会有特别大的问题,一下子就安装了几百个R包,但是呢,我在安装单细胞R包的时候居然报错了:

BiocManager::install( 'Seurat', suppressUpdates = FALSE, ask = FALSE)
# 报错如下
* DONE (sctransform)
ERROR: dependency ‘rsvd’ is not available for package ‘Seurat’
* removing ‘/usr/local/lib/R/library/Seurat’

The downloaded source packages are in
 ‘/tmp/Rtmpxrqg56/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages(...) :
 installation of package ‘Seurat’ had non-zero exit status

确实很诡异,但是只要你认真看报错,就不会有大问题的!

重新安装一下那个失败了的包

> BiocManager::install( 'rsvd', suppressUpdates = FALSE, ask = FALSE)
Bioconductor version 3.12 (BiocManager 1.30.10), R 4.0.3 (2020-10-10)
Installing package(s) 'rsvd'
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/rsvd_1.0.3.tar.gz'
Content type 'application/x-gzip' length 3422932 bytes (3.3 MB)
==================================================
downloaded 3.3 MB

* installing *source* package ‘rsvd’ ...
** package ‘rsvd’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rsvd)

The downloaded source packages are in
 ‘/tmp/Rtmpxrqg56/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
>

然后再安装你本来就想安装的包

BiocManager::install( 'Seurat', suppressUpdates = FALSE, ask = FALSE)
## 这次就没有问题了
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Seurat)

The downloaded source packages are in
 ‘/tmp/Rtmpxrqg56/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

但是我完全不知道为什么

仅仅是在看报错信息,然后推理,给出解决方案,实际上并不知道为什么有这样的报错发生。

Comments are closed.