Apt
在 Ubuntu 16.04 上安裝 Emacs25 軟體包時出錯
我正在嘗試在 Ubuntu 16.04 上安裝 Emacs25 軟體包以及 Emacs 24 和 Emacs-snapshot(目前為 Emacs 27.0.50)。
我執行了以下命令
sudo add-apt-repository ppa:kelleyk/emacs sudo apt-get update
之後我跑了
sudo apt install emacs25
在此期間我得到這個
user@user-desktop:$ sudo apt install emacs25 Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: emacs25-common The following NEW packages will be installed: emacs25 emacs25-common 0 upgraded, 2 newly installed, 0 to remove and 132 not upgraded. Need to get 0 B/21.0 MB of archives. After this operation, 90.8 MB of additional disk space will be used. Do you want to continue? [Y/n] y (Reading database ... 298195 files and directories currently installed.) Preparing to unpack .../emacs25-common_92792-c3ff671-emacs-25.2~ubuntu16.04.1_all.deb ... Unpacking emacs25-common (92792-c3ff671-emacs-25.2~ubuntu16.04.1) ... dpkg: error processing archive /var/cache/apt/archives/emacs25-common_92792-c3ff671-emacs-25.2~ubuntu16.04.1_all.deb (--unpack): trying to overwrite '/usr/share/emacs/site-lisp/subdirs.el', which is also in package emacs-snapshot-common 20190326:96618-9a6cba2~ubuntu16.04.1 dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) Selecting previously unselected package emacs25. Preparing to unpack .../emacs25_92792-c3ff671-emacs-25.2~ubuntu16.04.1_amd64.deb ... Unpacking emacs25 (92792-c3ff671-emacs-25.2~ubuntu16.04.1) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ... Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ... Rebuilding /usr/share/applications/bamf-2.index... Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for install-info (6.1.0.dfsg.1-5) ... Errors were encountered while processing: /var/cache/apt/archives/emacs25-common_92792-c3ff671-emacs-25.2~ubuntu16.04.1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
我該如何解決這個問題?
您可以使用您引用的輸出中的以下錯誤消息來解決此問題:
Unpacking emacs25-common (92792-c3ff671-emacs-25.2~ubuntu16.04.1) ... dpkg: error processing archive /var/cache/apt/archives/emacs25-common_92792-c3ff671-emacs-25.2~ubuntu16.04.1_all.deb (--unpack): trying to overwrite '/usr/share/emacs/site-lisp/subdirs.el', which is also in package emacs-snapshot-common 20190326:96618-9a6cba2~ubuntu16.04.1
安裝失敗,因為兩者
emacs-snapshot-common
都emacs25-common
包含/usr/share/emacs/site-lisp/subdirs.el
.有很多方法可以解決這個問題,但值得考慮的是,儘管 Emacs 包的名稱中包含版本號,但它們並非設計為可共同安裝的。(事實上,從 Debian 10 和 Ubuntu 18.10 開始,這些軟體包的名稱中不再包含版本號。)
解決這個問題的最乾淨的方法是轉移一個包的文件副本;例如,要保留
emacs25
的副本:sudo dpkg-divert --package emacs25 --divert /usr/share/emacs/site-lisp/subdirs.el.moved --rename /usr/share/emacs/site-lisp/subdirs.el
(語法相當違反直覺;有關詳細資訊,請參見手冊
dpkg-divert
頁)。subdirs.el
這會將其他包提供的任何版本重命名emacs25
為subdirs.el.moved
.