Score:5

The package system is broken in ubuntu 21.04 with php PPA

ve flag

I can't update ubuntu because the package system is broken.

below is the picture of error:

the system package is brken

after updating ubuntu I got this issue.

update 1:

I have tried these: sudo apt-get clean:

output:

(base) ☁  ~  sudo apt-get clean  
(base) ☁  ~  

, sudo apt-get install -f:

output:

(base) ☁  ~  sudo apt-get install -f
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:
  geoip-database libgeoip1 libnginx-mod-http-auth-pam libnginx-mod-http-cache-purge libnginx-mod-http-dav-ext
  libnginx-mod-http-fancyindex libnginx-mod-http-geoip libnginx-mod-http-headers-more-filter
  libnginx-mod-http-image-filter libnginx-mod-http-perl libnginx-mod-http-subs-filter
  libnginx-mod-http-uploadprogress libnginx-mod-http-upstream-fair libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-nchan libnginx-mod-stream libnginx-mod-stream-geoip libnginx-mod-stream-geoip2
  libpcre2-posix3
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libpcre2-posix2
The following NEW packages will be installed:
  libpcre2-posix2
0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
1 not fully installed or removed.
Need to get 8,300 B of archives.
After this operation, 33.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu impish/main amd64 libpcre2-posix2 amd64 10.39-2+ubuntu21.10.1+deb.sury.org+1 [8,300 B]
Fetched 8,300 B in 10s (812 B/s)           
(Reading database ... 320322 files and directories currently installed.)
Preparing to unpack .../libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre2-posix2:amd64 (10.39-2+ubuntu21.10.1+deb.sury.org+1) ...
dpkg: error processing archive /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libpcre2-posix.so.3', which is also in package libpcre2-posix3:amd64 10.37-0ubuntu2
Errors were encountered while processing:
 /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt --fix-broken install:

output:

(base) ☁  ~  sudo apt --fix-broken install
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:
  geoip-database libgeoip1 libnginx-mod-http-auth-pam libnginx-mod-http-cache-purge libnginx-mod-http-dav-ext
  libnginx-mod-http-fancyindex libnginx-mod-http-geoip libnginx-mod-http-headers-more-filter
  libnginx-mod-http-image-filter libnginx-mod-http-perl libnginx-mod-http-subs-filter
  libnginx-mod-http-uploadprogress libnginx-mod-http-upstream-fair libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-nchan libnginx-mod-stream libnginx-mod-stream-geoip libnginx-mod-stream-geoip2
  libpcre2-posix3
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libpcre2-posix2
The following NEW packages will be installed:
  libpcre2-posix2
0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
1 not fully installed or removed.
Need to get 0 B/8,300 B of archives.
After this operation, 33.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 320322 files and directories currently installed.)
Preparing to unpack .../libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre2-posix2:amd64 (10.39-2+ubuntu21.10.1+deb.sury.org+1) ...
dpkg: error processing archive /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libpcre2-posix.so.3', which is also in package libpcre2-posix3:amd64 10.37-0ubuntu2
Errors were encountered while processing:
 /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

and some other solutions, but didn't work.

Update 2:

A popup came from the system software updater and wanted to update. I updated and after that update, I have this issue

Update 3:

I didn't know which third-party app to remove, so I didn't remove any third-party apps.

update 4:

sudo apt update

(base) ☁  ~  sudo apt update
Hit:1 http://ppa.launchpad.net/ondrej/php/ubuntu impish InRelease
Hit:2 http://ppa.launchpad.net/papirus/papirus/ubuntu impish InRelease       
Hit:3 http://security.ubuntu.com/ubuntu impish-security InRelease                                                
Ign:4 http://nginx.org/packages/debian impish InRelease                     
Err:5 http://nginx.org/packages/debian impish Release                                                        
  404  Not Found [IP: 3.125.197.172 80]
Hit:6 http://af.archive.ubuntu.com/ubuntu impish InRelease                                                  
Hit:7 http://af.archive.ubuntu.com/ubuntu impish-updates InRelease                                    
Hit:8 http://af.archive.ubuntu.com/ubuntu impish-backports InRelease   
Hit:9 https://dl.google.com/linux/chrome/deb stable InRelease          
Reading package lists... Done
E: The repository 'http://nginx.org/packages/debian impish Release' does not have a Release file.
N: Updating from such a repository can't be done securely and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

sudo apt autoremove

(base) ☁  ~  sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  geoip-database libgeoip1 libnginx-mod-http-auth-pam libnginx-mod-http-cache-purge libnginx-mod-http-dav-ext
  libnginx-mod-http-fancyindex libnginx-mod-http-geoip libnginx-mod-http-headers-more-filter
  libnginx-mod-http-image-filter libnginx-mod-http-perl libnginx-mod-http-subs-filter
  libnginx-mod-http-uploadprogress libnginx-mod-http-upstream-fair libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-nchan libnginx-mod-stream libnginx-mod-stream-geoip libnginx-mod-stream-geoip2
  libpcre2-posix3
0 upgraded, 0 newly installed, 20 to remove and 0 not upgraded.
After this operation, 12.9 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 320326 files and directories currently installed.)
Removing geoip-database (20191224-3) ...
Removing libnginx-mod-stream-geoip (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-geoip (1.18.0-6ubuntu11) ...
Removing libgeoip1:amd64 (1.6.12-7) ...
Removing libnginx-mod-http-auth-pam (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-cache-purge (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-dav-ext (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-fancyindex (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-headers-more-filter (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-image-filter (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-perl (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-subs-filter (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-uploadprogress (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-upstream-fair (1.18.0-6ubuntu11) ...
Removing libnginx-mod-http-xslt-filter (1.18.0-6ubuntu11) ...
Removing libnginx-mod-mail (1.18.0-6ubuntu11) ...
Removing libnginx-mod-nchan (1.18.0-6ubuntu11) ...
Removing libnginx-mod-stream-geoip2 (1.18.0-6ubuntu11) ...
Removing libnginx-mod-stream (1.18.0-6ubuntu11) ...
Removing libpcre2-posix3:amd64 (10.37-0ubuntu2) ...
Processing triggers for nginx-light (1.18.0-6ubuntu11) ...
Triggering nginx reload ...
Processing triggers for libc-bin (2.34-0ubuntu3) ...
Nmath avatar
ng flag
Edit your question and include the output of `sudo apt update`, then `sudo apt-get install -f`, and `sudo apt upgrade`. Please copy/paste each output in its entirety. Use [code fences](https://askubuntu.com/editing-help#code) to preserve formatting. Also answer- did you remove 3rd party sources, as recommended in the error?
us flag
What did you do that broke the package system? Please [edit](https://askubuntu.com/posts/1377997/edit) the question to add that information.
Mahdi Jafari avatar
ve flag
I did update the question. could you help now?
us flag
Did you recently add any PPA?
Mahdi Jafari avatar
ve flag
Yeah, I think so.
Soren A avatar
mx flag
In your header you write that you are on Ubuntu 21.04 (Hirsute Hippo), but in the command output it shows that you have an Impish PPA - that is Ubuntu 21.10 and is bound to break ecerything.
Mahdi Jafari avatar
ve flag
I am experienced with Linux so I didn't know that.
Nmath avatar
ng flag
I don't see `sudo apt update` or `sudo apt upgrade` in your edit, but from your other commands I can see that you have packages that need to be autoremoved and you have 29 packages not upgraded. If you have been trying to install new software while your maintenance is not up-to-date, this could have caused your problems. Always run `sudo apt update` before doing anything else in apt. You should also upgrade packages before installing anything new. Please run `sudo apt update`, `sudo apt autoremove` and `sudo apt upgrade`. And edit your question with these outputs please
karel avatar
sa flag
Does this answer your question? [dpkg error: "trying to overwrite file, which is also in..."](https://askubuntu.com/q/176121/)
Score:18
us flag

If you really want to use the PPA

It seems that the package libpcre2-posix2 is trying to overwrite a library used by libpcre2-posix3.

Give apt the permission to overwrite the file.

sudo apt-get -o Dpkg::Options::="--force-overwrite" install libpcre2-posix2

Then, run sudo apt update, and sudo apt install -f and sudo apt upgrade.

If you don't want to use the PPA

The following command should remove the PPA and the conflicting packages.

sudo apt install ppa-purge
sudo ppa-purge ppa:ondrej/php
us flag
ppa-purge is a tool to cleanly remove a ppa. One has to install it first. I have edited my answer. If you don't want to remove the PPA, then don't run ppa-purge.
Nausif avatar
jp flag
@RaviMisra thanks, that worked for me too :)
Ravi Misra avatar
id flag
thanks, what worked for me on Ubuntu 20.04 is: `sudo apt-get -o Dpkg::Options::="--force-overwrite" install libpcre2-posix3` and then `sudo apt update && sudo apt upgrade`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.