有些时候警告会变成错误
经常就是打开R或者终端写shell脚本,就会发现下面这样的警告:
During startup - Warning message:
Setting LC_CTYPE failed, using "C"
通常我是选择无视它咯。
但也有时候,这个警告会成为致命错误。
比如安装一个GitHub来源的包:
BiocManager::install(c('remotes','devtools'),ask = F,update = F)
BiocManager::install('nik01010/dashboardthemes')
然后就报错了:
- preparing 'dashboardthemes':
v checking DESCRIPTION meta-information
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'dashboardthemes_1.0.2.tar.gz'
Error: (converted from warning) Setting LC_CTYPE failed, using "C"
Execution halted
Error in i.p(...) :
(converted from warning) installation of package '/tmp/RtmpzlA16W/file6a8b5d45db7b/dashboardthemes_1.0.2.tar.gz' had non-zero exit status
这个时候大家会误以为是 had non-zero exit status
这个问题,所以大家求助就集中火力在这里,实际上是不对的。
很容易思考一下,就应该是去其它电脑运行同样的代码看看,
加上两句代码:
Sys.setenv(LANG="en_US.UTF-8")
Sys.setenv(LC_ALL="en_US.UTF-8")
BiocManager::install('ggpubr',ask = F,update = F)
就成功了:
- building dashboardthemes_1.0.2.tar.gz
* installing *source* package 'dashboardthemes’ ...
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (dashboardthemes)
■ ■ ■