无法安装“bat”。错误:试图覆盖 '/usr/.crates2.json',它也在 ripgrep 11.0.2-1build1 包中

Mr.*_*Big 6 apt kubuntu

我正在尝试在 Kubuntu 上安装包bat。这是我目前的系统:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
Run Code Online (Sandbox Code Playgroud)

当我尝试安装“bat”时,我收到以下消息:

$ sudo apt install -y bat
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gir1.2-appindicator3-0.1 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-keybinder-3.0 gir1.2-wnck-3.0 gnome-session-canberra libappindicator3-1
  libcanberra-gtk3-0 libcanberra-gtk3-module libkeybinder-3.0-0 libwnck-3-0 libwnck-3-common libxres1 python3-gi-cairo
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  bat
0 upgraded, 1 newly installed, 0 to remove and 21 not upgraded.
Need to get 0 B/1.585 kB of archives.
After this operation, 4.325 kB of additional disk space will be used.
(Reading database ... 278687 files and directories currently installed.)
Preparing to unpack .../bat_0.12.1-1build1_amd64.deb ...
Unpacking bat (0.12.1-1build1) ...
dpkg: error processing archive /var/cache/apt/archives/bat_0.12.1-1build1_amd64.deb (--unpack):
 trying to overwrite '/usr/.crates2.json', which is also in package ripgrep 11.0.2-1build1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/bat_0.12.1-1build1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

如何修复我的系统以正确安装bat

Kan*_*sto 10

显然,这是 Rust 构建工具的问题。问题已经修复,在Ubuntu 20.10上可以正常安装包,但是在Ubuntu 20.04上还没有修复。

问题bathttps : //github.com/sharkdp/bat/issues/938

Ubuntu 问题:https : //bugs.launchpad.net/ubuntu/+source/rust-bat/+bug/1868517

根据 Ubuntu 问题,/usr/.crates2.json是一个“流浪”文件,并不重要。简单地删除它是不够的,因为包管理仍然知道它应该在那里。

作为解决方法,您可以忽略该问题并使用以下命令覆盖文件(此命令来自上述bat问题中的注释):

sudo apt install -o Dpkg::Options::="--force-overwrite" bat ripgrep
Run Code Online (Sandbox Code Playgroud)