程序員的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)
很有趣,爲什麼之前沒有啥影響的警告在這個時候就成了致命的錯誤呢?
■ ■ ■