Linux locale issue
案例1:
在debian下安裝程式時,有時候會因為本地設定沒有設定好,Per會給出下面的錯誤提示:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale
settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale
("C").
locale: Cannot set LC_CTYPE to default locale: No such file
or directory
locale: Cannot set LC_MESSAGES to default
locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No
such file or directory
要解決這個問題,其實很簡單,只要執行下面幾條命令,一切都會OK:
debian:~# apt-get install locales
debian:~# dpkg-reconfigure locales
debian:~# locale
一切都會OK? 不一定,看下面的帖子。
--------------------------------------------------------------------------------------------------------------
http : // askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue
I am getting this message every time I do something like starting or stopping a service. perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LC_MESSAGES = "en_US.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory (Reading database ... 21173 files and directories currently installed.) Removing bind9 ... * Stopping domain name service... bind9 [ OK ] Processing triggers for man-db ... locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory How do I fix this error ? |
通用的第一招:
First run locale to list what locales currently defined for the current user account:
$ locale
LANG=C
LANGUAGE=
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY="C"
LC_MESSAGES=fi_FI.UTF-8
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
Then generate the missing locale and reconfigure locales to take notice:
$ sudo locale-gen "en_US.UTF-8"
Generating locales...
en_US.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
Now you will not see any errors anymore!
如果第一招不靈:
比如Umair 反饋說: did not work for me – Umair
Ivan Buttinoni又支了一招
@UmairAyub may be you have more than one unknow locale, try this: for y in $(locale | cut -d '=' -f 2| sort |uniq );do locale-gen $y; done It will generate a locale for each definition you have – Ivan Buttinoni
另外,設定環境變數也可以解決這個問題:
putting to the file /etc/environment:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
或者更新到/etc/default/locale
sh -c "echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale"
如果是在遠端連線時報的這個錯誤,可以使用下面的方法:
This is a common problem if you are connecting remotely, so the solution is to not forward your locale. Edit /etc/ssh/ssh_config and comment out SendEnv LANG LC_* line.
On OSX (connecting to ubuntu) it's at /etc/ssh_config
One-liner to do this: sed -e '/SendEnv/ s/^#*/#/' -i /etc/ssh/ssh_config (useful for server provisioning)
update-locale命令做了什麼?
here is a command for that:
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
It updates /etc/default/locale with provided values.
dpkg-reconfigure locales可能什麼返回都沒有,需要安裝語言包:
What worked for me on 12.10 was this:
apt-get install language-pack-en-base
This was after dpkg-reconfigure locales produced no results.
其他還有很多補充,比如使用KDE時怎麼辦.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-2075885/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Windows Locale Codes Sorted by LocaleWindows
- Linux-關於locale的設定(轉)Linux
- issue
- LINUX系統程式設計 LINUX地區(locale)設定Linux程式設計
- Linux中通過locale來設定字符集Linux
- PostgreSQL DBA(42) - localeSQL
- Oracle LOB issueOracle
- Flutter Weekly Issue 44Flutter
- rac vip failback issueAI
- FreeMarker boolean IssueBoolean
- Linux裡面locale命令有何作用?語法格式是什麼?Linux
- Linux下perldoc亂碼延伸至LANG,LC_ALL,locale探討Linux
- 關於locale的設定
- Oracle Performance Top Issue listOracleORM
- locale 詳解 字符集概念
- Check connection related issue of mysqlMySql
- EOSIO MySQL 外掛 issue 2MySql
- EOSIO MySQL 外掛 issue 1MySql
- LANG,LC_ALL,locale詳解(轉)
- 對與locale和resourceBundle的理解
- Android Weekly Notes Issue #255Android
- Oracle BI Answers Direct Database Request issueOracleDatabase
- Step 7: Issue the CREATE DATABASE Statement (65)Database
- Rapid clone issue on R12API
- linux登入locale告警-bash: warning: setlocale: LC_TIME: cannot change的處理方法Linux
- couldn't set locale correctly報錯解決
- 禁止 SSH 傳遞 locale 環境變數變數
- 如何使用 Issue 管理軟體專案?
- Oracle blocking issue with lock table in exclusive modeOracleBloC
- Eclipse : Web Deployment Assembly & Maven dependencies issueEclipseWebMaven
- oracle JRE issue using runInstallerOracle
- /etc/motd與/etc/issue的區別
- issue: java.lang.NoClassDefFoundError: javax/el/ELManagerJavaError
- ABAP開發的Github issue備份工具Github
- GitHub 新支援在 issue 插入程式碼段Github
- Solving ODI "Initializing Search Engine" issue
- Oracle Doc list involved with upgrade issueOracle
- 徹底弄懂UTF-8、Unicode、寬字元、localeUnicode字元