1

I uninstalled php5 from my computer with command

sudo apt-get -y purge php.*

running this command will show me this message in terminal:

Errors were encountered while processing: php5-memcache php5-memcached

So I tried to uninstall memcache:

sudo apt-get remove php-memcache

It showed me message, that it cannot find memcache package:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php-memcache

and then memcached:

apt-get remove php5-memcached

It throws me information about missing dependencies in php:

The following packages have unmet dependencies.
php5-memcache : Depends: php5-common (>= 4.3.11) but it is not going to be installed  
      Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
      Depends: phpapi-20121212
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Running

apt-get -f install

throws me errors about removing memcache, again.

As I understand correctly, I made mistake, that I didn't remove memcache before I uninstalled php5? What can I do now? Do I need to install php again? When I try to install missing dependencies, I get message about another missing packages. Should not be missing packages automatically added/removed, when using "apt-get"?

By googling I found, that problem can be by using wrong repositories, which are not suitable for my system. How can I detect, which repositories are the right for my system to install/unistall appropriate packages for uninstalling memcache? thanks for any help

I have such php repositories added to my system: http://ppa.launchpad.net/ondrej/php5/ubuntu http://ppa.launchpad.net/ondrej/php5/ubuntu http://ppa.launchpad.net/ondrej/php-7.0/ubuntu http://ppa.launchpad.net/ondrej/php-7.0/ubuntu

I tried to remove memcache with dpkg according @oerdnj but I got still some errors:

tomas@Toshiba ~ $ sudo dpkg --purge php5-memcache
(Reading database ... 275094 files and directories currently   installed.)
Removing php5-memcache (3.0.8-4build1) ...
/var/lib/dpkg/info/php5-memcache.prerm: 9: /var/lib/dpkg/info/php5-  memcache.prerm: php5dismod: not found
dpkg: error processing package php5-memcache (--purge):
subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
php5-memcache

I also tried solution from thread How to remove/install a package that is not fully installed? but it shows me the same errors:

tomas@Toshiba ~ $ sudo apt-get install --reinstall dpkg
[sudo] password for tomas: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
php5-memcache : Depends: php5-common (>= 4.3.11) but it is not going      to be installed
Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
             Depends: phpapi-20121212
php5-memcached : Depends: libmemcached10 but it is not going to be installed
              Depends: php5-common (>= 5.2.0) but it is not going to be installed
              Depends: php5-common (< 6.0.0) but it is not going to be installed
              Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
              Depends: phpapi-20121212
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

2 Answers2

1

If your system is in state where apt-get is mostly unusable you could try using dpkg to remove the affected package, in this case try:

sudo dpkg --purge php5-memcache

dpkg is a low-level tool to manipulate packages and it's not trying so hard to have all packages in consistent state.

Since php5dismod is missing from your system I would simply recommend removing the /var/lib/dpkg/info/php5-memcache.prerm and /var/lib/dpkg/info/php5-memcache.postrm files and cleaning /etc/php5/ by hand for traces of memcache configuration (main memcache.ini symlinked to 20-memcache.ini might be found there).

Note: Please do not try other random things from the internet, you might broke the system even more, if you do not fully understand what you are doing.

oerdnj
  • 7,940
0

I had this issue after updating to Ubuntu 16.04 from 14.04.

If you open var/lib/dpkg/info/php5-memcached.prerm you'll see this contents:

#!/bin/sh

set -e

dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/memcached.ini \
    /etc/php5/mods-available/memcached.ini 2.0.1-3 -- "$@"
rm -f /etc/php5/conf.d/memcached.ini

[ "$1" = "remove" ] && php5dismod memcached

exit 0

The easiest way to fix the error is to just comment out the php5dismod line:

#!/bin/sh

set -e

dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/memcached.ini \
    /etc/php5/mods-available/memcached.ini 2.0.1-3 -- "$@"
rm -f /etc/php5/conf.d/memcached.ini

# !!!!!!!!!!
# Do _not_ do anything with php5dismod
# [ "$1" = "remove" ] && php5dismod memcached
# !!!!!!!!!!

exit 0

After this you can run sudo apt-get -f install again and it'll remove it without an issue.

h2ooooooo
  • 119