从 13.04 更新至 13.10 时,do-release-upgrade 在解码 () 时发生 UnicodeDecodeError 崩溃

从 13.04 更新至 13.10 时,do-release-upgrade 在解码 () 时发生 UnicodeDecodeError 崩溃

我刚刚尝试从 13.04 升级到 13.10,但在控制台中收到以下错误

Checking for a new Ubuntu release
authenticate 'saucy.tar.gz' against 'saucy.tar.gz.gpg' 
extracting 'saucy.tar.gz'
Traceback (most recent call last):
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/saucy", line 10, in <module>
    sys.exit(main())
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/DistUpgrade/DistUpgradeMain.py", line 240, in main
    save_system_state(logdir)
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/DistUpgrade/DistUpgradeMain.py", line 133, in save_system_state
    scrub_sources=True)
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/DistUpgrade/apt_clone.py", line 149, in save_state
    self._write_state_sources_list(tar, scrub_sources)
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/DistUpgrade/apt_clone.py", line 241, in _write_state_sources_list
    "./etc/apt/sources.list.d/"+source)
  File "/tmp/user/0/ubuntu-release-upgrader-xnzjbd/DistUpgrade/apt_clone.py", line 246, in _add_file_to_tar_with_password_check
    for line in f.readlines():
  File "/usr/lib/python2.7/codecs.py", line 296, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9f in position 3: invalid start byte

update-manager这是我在gui中得到的结果

do-release-upgrade crashed on UnicodeDecodeError in decode(): 'utf8' codec can't decode byte 0x9f in position 3 : invalid state

答案1

检查 sources.list.d 中是否有任何包含二进制垃圾(python unicode 解码器会删除这些垃圾)的点文件(以句点开头的文件)。我遇到了同样的问题,当我从 /etc/apt/sources.list.d/ 中删除点文件后,它又恢复了正常。

答案2

对于有类似问题的人来说,最简单的解决方案是:

export LC_ALL=C.UTF-8
export LANG=C.UTF-8
do-release-upgrade

UTF-8非常简单。而且这可以解决与任何类型的安装相关的许多类似问题。相信我!

答案3

我有一个稍微不同的原因和解决方案,但 user204109 的回答对此有所帮助。

基本上,我在之前的 dist 升级脚本插入的文件中有一些不符合 utf-8 标准的字符/etc/apt/sources.list.d/。这是因为我的母语中有一些非 ASCII 字符,而且显然之前的本地化不太正确。

找到罪魁祸首的最简单方法是运行:

cd /etc/apt/sources.list.d
file *.list

然后在编辑器中打开每个未列为“ASCII 文本”的文件,并删除任何看起来像垃圾的字符。

相关内容