I'm trying to install the package bat on Kubuntu. This is my current system:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

When I try to install "bat", I get this message:

$ 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:
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:
E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I fix my system to correctly install bat?

2 Answers 2


Apparently, this is an issue with the Rust build tools. The issue has already been fixed, and the packages can be installed normally on Ubuntu 20.10, but the fix has not yet arrived to Ubuntu 20.04.

Issue for bat: https://github.com/sharkdp/bat/issues/938

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

According to the Ubuntu issue, /usr/.crates2.json is a "stray" file, and not important. Simply removing it is not enough, because package management still knows that it should be there.

As a workaround, you can ignore the issue and overwrite the file with the command (this command is from the comments in the above bat issue):

sudo apt install -o Dpkg::Options::="--force-overwrite" bat ripgrep
  • 1
    sudo apt install --fix-broken -o Dpkg::Options::="--force-overwrite" helped me with a related issue (same error as OP, but with apt upgrade) when trying to upgrade nvidia drivers on Ubuntu 21.04. Jul 27, 2021 at 15:50

I install bat first, then fail installing ripgrep.


sudo dpkg -i --force-overwrite /var/cache/apt/archives/ripgrep_11.0.2-1build1_amd64.deb

this may varies: /var/cache/apt/archives/ripgrep_11.0.2-1build1_amd64.deb

  • A bit of warning is usually in order when using any --force option. While it solves today's problem, it may create more severe future problems. In addition, a bug report to the package maintainers is often appropriate; they did not usually intend for their packages to conflict.
    – user535733
    Nov 15, 2021 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .