程序员的3个美德,其中之一就是懒惰,凡是不影响大局的代码警告我都懒得去解决,比如每次启动R语言都会有:
Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. During startup - Warning messages: 1: Setting LC_CTYPE failed, using "C" 2: Setting LC_COLLATE failed, using "C" 3: Setting LC_TIME failed, using "C" 4: Setting LC_MESSAGES failed, using "C" 5: Setting LC_MONETARY failed, using "C"
这样的警告信息,因为不影响R的继续使用,所以我通常是视而不见。
但是在安装一个R包的时候终于开始报错了,而且错误信息表明是之前的这个警告:
> devtools::install_github("mskcc/pctGCdata") Downloading GitHub repo mskcc/pctGCdata@master tar: Failed to set default locale tar: Failed to set default locale During startup - Warning messages: 1: Setting LC_CTYPE failed, using "C" 2: Setting LC_TIME failed, using "C" 3: Setting LC_MESSAGES failed, using "C" 4: Setting LC_MONETARY failed, using "C" v checking for file '/private/var/folders/2x/l4fzfvy17gz94j1sz6klhyjh0000gn/T/RtmpH50TBq/remotes4f18707324d6/mskcc-pctGCdata-c199831/DESCRIPTION' ... - preparing 'pctGCdata': v checking DESCRIPTION meta-information ... - installing the package to process help pages - saving partial Rd database (2m 1.2s) - checking for LF line-endings in source and make files and shell scripts - checking for empty or unneeded directories - looking to see if a 'data/datalist' file should be added - building 'pctGCdata_0.2.0.tar.gz' Error: (converted from warning) Setting LC_CTYPE failed, using "C" Execution halted Error in i.p(...) : (converted from warning) installation of package '/var/folders/2x/l4fzfvy17gz94j1sz6klhyjh0000gn/T//RtmpH50TBq/file4f18184bb97f/pctGCdata_0.2.0.tar.gz' had non-zero exit status
所以迫使我不得不去搜索解决方案,查到:
https://stackoverflow.com/questions/9689104/installing-r-on-mac-warning-messages-setting-lc-ctype-failed-using-c 这样的MAC解决方案,所以我打开我的mac终端,去敲入代码:
defaults write org.R-project.R force.LANG en_US.UTF-8
然后重启R语言,再次进入代码编辑器,重新安装这个R包,解决问题!!!
成功安装信息如下:
> devtools::install_github("mskcc/pctGCdata") Downloading GitHub repo mskcc/pctGCdata@master ✔ checking for file ‘/private/var/folders/2x/l4fzfvy17gz94j1sz6klhyjh0000gn/T/RtmpUXwAea/remotes51b3692788c/mskcc-pctGCdata-c199831/DESCRIPTION’ ... ─ preparing ‘pctGCdata’: ✔ checking DESCRIPTION meta-information ... ─ installing the package to process help pages ─ saving partial Rd database (2m 3.6s) ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories ─ looking to see if a ‘data/datalist’ file should be added ─ building ‘pctGCdata_0.2.0.tar.gz’ * installing *source* package ‘pctGCdata’ ... ** R ** data *** moving datasets to lazyload DB ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded * DONE (pctGCdata)
很有趣,为什么之前没有啥影响的警告在这个时候就成了致命的错误呢?
■ ■ ■