Emacs 在 Ubuntu 20.04 上安装失败。

我只是想简单地做以下事情:
sudo apt install emacs

在Ubuntu 20.04上。
结果是似乎在安装emacs的所有依赖项之一,即emacsen-commonemacs-gtk时出现了错误。我看到的错误是:
Setting up emacs-gtk (1:26.3+1-1ubuntu2) ...
Install emacsen-common for emacs
emacsen-common: Handling install of emacsen flavor emacs
emacs: error while loading shared libraries: libotf.so.0: cannot open shared object file: No such file or directory
ERROR: install script from emacsen-common package failed
dpkg: error processing package emacs-gtk (--configure):
 installed emacs-gtk package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of emacs:
 emacs depends on emacs-gtk (>= 1:26.3) | emacs-lucid (>= 1:26.3) | emacs-nox (>= 1:26.3); however:
  Package emacs-gtk is not configured yet.
  Package emacs-lucid is not installed.
  Package emacs-nox is not installed.

dpkg: error processing package emacs (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 emacs-gtk
 emacs
E: Sub-process /usr/bin/dpkg returned an error code (1)


我希望能获得一些关于如何解决这个问题的想法。

1我遇到了同样的问题。还不知道如何正确安装emacs,但是通过运行sudo dpkg --remove --force-remove-reinstreq来处理每个存在未满足依赖关系的软件包,成功将apt恢复到正常状态。 - LyteFM
1我通过在清除emacs后运行sudo apt install --reinstall libotf0 libm17n-0来解决了这个问题。不知道为什么它有效,但确实有效。 - sanimalp
很好,这对我也有效。 - LyteFM
5个回答

为了解决这个问题,我首先执行了sudo apt purge emacs
然后,我使用以下命令重新安装了libotf0和libm17n-0: sudo apt install --reinstall libotf0 libm17n-0 之后,sudo apt install emacs按预期工作。

1嗯,你有这个的 PPA 吗?对我来说出现了错误,“无法找到软件包 libotf0”。 - Jeff Ward

这需要使用libotf1而不是libotf0。所以请按照以下步骤操作:
首先执行sudo apt purge emacs
然后重新安装libotf1libm17n-0,使用命令: sudo apt install --reinstall libotf1 libm17n-0 之后,执行sudo apt install emacs,应该能正常工作。

重新安装emacs-gtk对我来说起作用了。
sudo apt install --reinstall emacs-gtk 

然后重新安装emacs
sudo apt install emacs

希望这能帮到你。

我遇到了一个类似的问题,安装emacs-gtk时出现了后安装脚本错误,似乎与elpa-company包有关。这在从Kubuntu 20.10升级到21.04和运行21.04期间都发生过。
感谢大家给出的好建议,在尝试了几种方法后,问题在我清除了所有emacs*软件包后得到解决:
sudo dpkg --purge --force-depends emacs emacs-common ...
然后使用以下命令安装除emacs和emacs-gtk之外的所有emacs*软件包:
apt-get download sudo dpkg -i --force-depends 最后按照上述步骤安装emacs-gtk,并最终安装emacs(sudo apt install emacs)。

还有另一种方法可以做到:通过snap store使用snap软件包。