我昨晚通过 dpkgsougoupinyin
从文件安装了一个软件包sougoupinyin.deb
。我记得有一些缺失的依赖项我不知道如何处理。
重新启动计算机后,我尝试通过 apt 安装一些其他软件包。但是,我遇到了这个错误:
littlewhole@pop-os:~$ sudo apt-get install fcitx fcitx-mozc kde-config-fcitx
Reading package lists... Done
Building dependency tree
Reading state information... Done
fcitx is already the newest version (1:4.2.9.7-3).
kde-config-fcitx is already the newest version (0.5.5-2build1).
The following packages will be REMOVED:
sogoupinyin
The following NEW packages will be installed:
fcitx-mozc
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 247 kB of archives.
After this operation, 57.2 MB disk space will be freed.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 fcitx-mozc amd64 2.23.2815.102+dfsg-8ubuntu1 [247 kB]
Fetched 247 kB in 0s (1,190 kB/s)
(Reading database ... 235083 files and directories currently installed.)
Removing sogoupinyin (2.2.0.0108) ...
/var/lib/dpkg/info/sogoupinyin.postrm: 8: local: debian": bad variable name
dpkg: error processing package sogoupinyin (--remove):
installed sogoupinyin package post-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
sogoupinyin
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
然后我尝试通过 dpkg 重新安装软件包,并得到几乎相同的错误:
littlewhole@pop-os:~$ sudo dpkg -i '/home/littlewhole/sogoupinyin.deb'
Selecting previously unselected package sogoupinyin.
(Reading database ... 235083 files and directories currently installed.)
Preparing to unpack .../littlewhole/sogoupinyin.deb ...
Unpacking sogoupinyin (2.2.0.0108) over (2.2.0.0108) ...
/var/lib/dpkg/info/sogoupinyin.postrm: 8: local: debian": bad variable name
dpkg: warning: old sogoupinyin package post-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/postrm: 8: local: debian": bad variable name
dpkg: error processing archive /home/littlewhole/sogoupinyin.deb (--install):
new sogoupinyin package post-removal script subprocess returned error exit status 2
/var/lib/dpkg/tmp.ci/postrm: 8: local: debian": bad variable name
dpkg: error while cleaning up:
new sogoupinyin package post-removal script subprocess returned error exit status 2
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for libglib2.0-0:i386 (2.64.2-1~fakesync1) ...
Processing triggers for libglib2.0-0:amd64 (2.64.2-1~fakesync1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
/home/littlewhole/sogoupinyin.deb
然后我尝试通过 dpkg 卸载该软件包,却收到以下错误:
littlewhole@pop-os:~$ sudo dpkg -r sougoupinyin
dpkg: warning: ignoring request to remove sougoupinyin which isn't installed
此时我决定去askubuntu看看是否有其他人遇到类似的问题并解决了。我找到了一个答案,表明运行此命令可以修复它:
sudo rm -rf /var/lib/dpkg/info/sougoupinyin.*
sudo rm -rf /usr/share/sougoupinyin
sudo rm -rf /etc/default/sougoupinyin
sudo rm -rf /etc/init.d/sougoupinyin
sudo apt purge sougoupinyin
我决定运行这个。 rm 操作成功完成,但apt purge
再次遇到错误:
littlewhole@pop-os:~$ sudo apt purge sougoupinyin
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package sogoupinyin needs to be reinstalled, but I can't find an archive for it.
在浏览了更多问题和答案后,我决定尝试一下sudo apt-get -f install
,但可惜的是,另一个错误:
littlewhole@pop-os:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package sogoupinyin needs to be reinstalled, but I can't find an archive for it.
最后,我尝试了sudo dpkg --remove --force-remove-reinstreq sougoupinyin
。但即使这样也会引发错误:
littlewhole@pop-os:~$ sudo dpkg --remove --force-remove-reinstreq sougoupinyin
dpkg: warning: ignoring request to remove sougoupinyin which isn't installed
此时,我的系统处于“此软件包存在,您必须重新安装它”和“此软件包未安装”之间的中间状态。我尝试通过 dpkg 重新安装相同的 .deb,但仍然出现错误:
littlewhole@pop-os:~$ sudo dpkg -i '/home/littlewhole/sogoupinyin.deb'
(Reading database ... 235083 files and directories currently installed.)
Preparing to unpack .../littlewhole/sogoupinyin.deb ...
Unpacking sogoupinyin (2.2.0.0108) over (2.2.0.0108) ...
/var/lib/dpkg/info/sogoupinyin.postrm: 8: local: debian": bad variable name
dpkg: warning: old sogoupinyin package post-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/postrm: 8: local: debian": bad variable name
dpkg: error processing archive /home/littlewhole/sogoupinyin.deb (--install):
new sogoupinyin package post-removal script subprocess returned error exit status 2
/var/lib/dpkg/tmp.ci/postrm: 8: local: debian": bad variable name
dpkg: error while cleaning up:
new sogoupinyin package post-removal script subprocess returned error exit status 2
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for libglib2.0-0:i386 (2.64.2-1~fakesync1) ...
Processing triggers for libglib2.0-0:amd64 (2.64.2-1~fakesync1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
/home/littlewhole/sogoupinyin.deb
现在,apt
正被这些错误所阻碍。我无法通过apt
.这显然是一个问题。我无法重新安装或删除此软件包,并且它无法正常工作apt
。我应该怎么办?
答案1
正如消息中所暗示的,第 8 行存在一个问题/var/lib/dpkg/info/sogoupinyin.postrm
,即删除后程序。
如果您有信心,您可以编辑此文件(以 root 身份)并解决问题,或者如果您确定错误行不是无害的,甚至可以对错误行进行注释。
然后apt-get remove sogoupinyin
应该可以工作。