有些时候警告会变成错误
经常就是打开R或者终端写shell脚本,就会发现下面这样的警告:
During startup - Warning message:
Setting LC_CTYPE failed, using "C"
```<img class="wp-more-tag mce-wp-more" title="阅读更多…" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" data-wp-more="more" data-mce-resize="false" data-mce-placeholder="1" data-mce-src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
通常我是选择无视它咯。
但也有时候,这个警告会成为致命错误。
比如安装一个GitHub来源的包:
```r
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)