dpkg: error processing archive /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb (--unpack):

When I am running sudo apt-get -f install, it shows dpkg: error processing. Please find the complete logs below and advise how to solve this. I am running VB 5.0.10 with Ubuntu 16.04 and already installed go 1.8 and its working fine

sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  bridge-utils containerd gir1.2-cogl-1.0 gir1.2-freedesktop:i386 gir1.2-gdkpixbuf-2.0:i386 gir1.2-glib-2.0:i386
  gir1.2-pango-1.0:i386 libc6-dev:i386 libcaca-dev libcairo-gobject2:i386 libcairo-script-interpreter2:i386 libdmx-dev libdmx1
  libedata-cal-1.2-28 libepoxy-dev libexpat1-dev:i386 libfontconfig1-dev:i386 libfontenc-dev libfreetype6-dev:i386 libfribidi-dev
  libfs-dev libfs6 libgeocode-glib0 libgirepository-1.0-1:i386 libglu1-mesa-dev libgmp-dev libgmpxx4ldbl libgweather-common
  libharfbuzz-gobject0:i386 libharfbuzz-icu0:i386 libice-dev:i386 libice6:i386 libicu55:i386 libilmbase12 libjpeg-turbo8-dev
  liblzo2-2:i386 libopenexr22 libpangox-1.0-0 libpciaccess-dev libpcre16-3:i386 libpcre3-dev:i386 libpcre32-3:i386
  libpcrecpp0v5:i386 libpng12-dev:i386 libsdl1.2debian libslang2-dev libsm-dev:i386 libsm6:i386 libvte-common libxaw7-dev
  libxcb-render0-dev:i386 libxcb-shm0-dev:i386 libxext-dev:i386 libxfont-dev libxkbfile-dev libxmu-dev libxmu-headers libxmuu-dev
  libxpm-dev libxrender-dev:i386 libxres-dev libxss-dev libxt-dev libxv-dev libxvmc-dev libxxf86dga-dev linux-headers-4.4.0-64
  linux-headers-4.4.0-64-generic linux-headers-4.4.0-66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-67
  linux-headers-4.4.0-67-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic linux-headers-4.4.0-71
  linux-headers-4.4.0-71-generic linux-headers-4.4.0-72 linux-headers-4.4.0-72-generic linux-image-4.4.0-64-generic
  linux-image-4.4.0-66-generic linux-image-4.4.0-67-generic linux-image-4.4.0-70-generic linux-image-4.4.0-71-generic
  linux-image-4.4.0-72-generic linux-image-extra-4.4.0-64-generic linux-image-extra-4.4.0-66-generic
  linux-image-extra-4.4.0-67-generic linux-image-extra-4.4.0-70-generic linux-image-extra-4.4.0-71-generic
  linux-image-extra-4.4.0-72-generic linux-libc-dev:i386 mir-client-platform-mesa-dev nettle-dev par2 python-cairo python-gobject-2
  runc ubuntu-fan x11proto-bigreqs-dev x11proto-dmx-dev x11proto-dri3-dev x11proto-fonts-dev x11proto-present-dev
  x11proto-resource-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev
  x11proto-xf86dri-dev zlib1g-dev:i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  golang-1.6-go
Suggested packages:
  bzr
The following packages will be upgraded:
  golang-1.6-go
1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
44 not fully installed or removed.
Need to get 0 B/20.3 MB of archives.
After this operation, 3,072 B of additional disk space will be used.
Do you want to continue? [Y/n] y 
(Reading database ... 453044 files and directories currently installed.)
Preparing to unpack .../golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb ...
Unpacking golang-1.6-go (1.6.2-0ubuntu5~16.04.2) over (1.6.2-0ubuntu5~16.04) ...
dpkg: error processing archive /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/go-1.6/src', which is also in package golang-1.6-race-detector-runtime 0.0+svn252922-0ubuntu1
Errors were encountered while processing:
 /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Answers

That is a bug in the packaging in Ubuntu. This was already reported here: https://bugs.launchpad.net/ubuntu/+source/golang-1.6/+bug/1691834

It is likely that as a workaround you can first uninstall golang-1.6-race-detector-runtime, then running apt-get install might work.

Posted on by Jan Zerebecki