'"apt upgrade -y" Not working in kali linux (The following packages have unmet dependencies)

While updating kali machine the following error will shown

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 codeblocks-dev : Depends: libcodeblocks0 (= 20.03) but 20.03-3.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

and after this i try to fixing issue by typing command apt --fix-broken install but!!!

└─# apt --fix-broken install                                                                                                                                    100 ⨯
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  fastjar jarwrapper kali-wallpapers-2021.4 libaom0 libcbor0 libcodec2-0.9 libfluidsynth2 libfmt7 libgdal29 libgdk-pixbuf-xlib-2.0-0 libgdk-pixbuf2.0-0 libigdgmm11
  libodbc1 libodbccr2 libqhull8.0 libwireshark14 libwiretap11 libwsutil12 odbcinst odbcinst1debian2 python3-orjson ruby-atomic ruby-thread-safe
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  codeblocks-dev
The following packages will be upgraded:
  codeblocks-dev
1 upgraded, 0 newly installed, 0 to remove and 270 not upgraded.
1 not fully installed or removed.
Need to get 0 B/522 kB of archives.
After this operation, 1,637 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 350701 files and directories currently installed.)
Preparing to unpack .../codeblocks-dev_20.03-3.1_amd64.deb ...
Unpacking codeblocks-dev:amd64 (20.03-3.1) over (20.03) ...
dpkg: error processing archive /var/cache/apt/archives/codeblocks-dev_20.03-3.1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/codeblocks/Alignment.h', which is also in package codeblocks-headers 20.03
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/codeblocks-dev_20.03-3.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Nothing happend!!



Solution 1:[1]

try using

apt dist-upgrade -y 

then

apt update && apt upgrade -y 

it might help

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Avin