210

I used source code to build one package such as below:

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/lib --with-package-name="Myplugin" --with-package-origin="http://www.ubuntu.org/" --enable-gtk-doc --disable-static
make
make install

But unfortunately, i discovered that its the latest version, and has lot of bugs, so i need to remove it/uninstall it. But how can i do so? I tried make clean; make uninstall but still i see it exist:

# pkg-config --list-all | grep Myplugin
myplugin-....
$ ls /usr/lib/myplugin/libXYZ.so
exist....

How do you remove this now?

0

10 Answers 10

271

Usually you can just use:

make uninstall

or

sudo make uninstall

if the app was installed as root.

But this will work only if the developer of the package has taken care of making a good uninstall rule.

You can also try to get a look at the steps used to install the software by running:

make -n install

And then try to reverse those steps manually.

In the future to avoid that kind of problems try to use checkinstall instead of make install whenever possible (AFAIK always unless you want to keep both the compiled and a packaged version at the same time). It will create and install a deb file that you can then uninstall using your favorite package manager.

make clean usually cleans the building directories, it doesn't uninstall the package. It's used when you want to be sure that the whole thing is compiled, not just the changed files.

8
  • 60
    +1 for using checkinstall - it makes this whole problem evaporate.
    – Oli
    Dec 12, 2011 at 12:00
  • 8
    @Google: If make uninstall doesn't work, you'll need to track what make install did and undo it manually. Dec 12, 2011 at 12:42
  • 1
    Does make uninstall work after a make clean? I believe to need to make sure it's still ./configured'd the same way.
    – user606723
    Dec 12, 2011 at 16:10
  • 4
    Another thing to keep in mind is that if make install was run as root (e.g., sudo make install), which is typically the case, it's virtual always necessary to run sudo make uninstall to remove the software. Jul 9, 2013 at 1:46
  • 7
    If you have already run make install, you can still use checkinstall. Normally checkinstall will overwrite everything that make install created. After that just use dpkg -r <package.deb>, and everything should be removed.
    – user502144
    Oct 15, 2017 at 18:00
33

I do not think this is a bug, it would be a good idea to read about and learn to use checkinstall when installing from source.

you can install checkinstall from the repositories, a short description of the package;

CheckInstall keeps track of all the files created or modified by your installation script ("make install" "make install_modules", "setup", etc), builds a standard binary package and installs it in your system giving you the ability to uninstall it with your distribution's standard package management utilities.

These links below may be helpful to get a better understanding. http://en.wikipedia.org/wiki/CheckInstall

http://checkinstall.izto.org/

0
18

This is not a bug - compiling from source is an unsupported method of installing software that bypasses the package management system (which is used by the Software Centre) completely.

There is no standard way that software compiled from source is installed or uninstalled so no way Ubuntu can know what to do. The software is not even listed as an installed program.

You should follow the distributor's instructions for installation and removal of such custom software. You could also contact the developer to ask for them to create a Debian package so that the package management system can be used.

9

Make

Make is a program that’s used to compile and install programs from source code. It’s not a package manager so it doesn’t keep track of the files it installs. This makes it difficult to uninstall the files afterwards.

The make install command copies the built program and packages into the library directory and specified locations from the makefile. These locations can vary based on the examination that’s performed by the configure script.

CheckInstall

CheckInstall is a program that’s used to install or uninstall programs that are compiled from the source code. It monitors and copies the files that are installed using the make program. It also installs the files using the package manager which allows it to be uninstalled like any regular package.

The checkinstall command is calls the make install command. It monitors the files that are installed and creates a binary package from them. It also installs the binary package with the Linux package manager.

Replace source_location.deb and name in the screenshot with your own information:

Screenshot

Execute the following commands in the source package directory:

  1. Install CheckInstall

    sudo apt-get install checkinstall
    
  2. Run the Configure script

    ./configure
    
  3. Run the Make command

    make
    
  4. Run CheckInstall

    sudo checkinstall
    
  5. Reinstall the package

    sudo dpkg --install --force-overwrite source_location.deb
  6. Remove the package

    sudo apt remove name

Here's an article I wrote that goes through the entire process with explanations.

4

It is not a bug, it is what happens when developers resort to distribution via source and not via the native packaging methods.

You can get your source files to become debian packages by using checkinstall or dhbuild. Honestly, in my opinion - new users should avoid installing from source, and developers should avoid distributing by source only.

1
  • I know but sometimes it is unavoidable...In this case it was just a small game which is not really necessary but sometime back I had to install MATLAB a computational tool used in my university and had to install it by the source since they did not have a deb file for ubuntu...But I will definitely go through the methods checkinstall and dhbuild...thanks
    – nik90
    Jan 20, 2011 at 22:44
3

We need to negotiate the fact that make uninstall would not always work, so below is more of a proactive solution.

This involves the use of the paco program which is available in the Ubuntu Software Center. Once we have installed paco, we can use it the log mode when we "make install" a program. Paco acts like a wrapper for your "make install" and creates a log in the /var/log/paco directory with the list of files copied to various directories. Moreover, you could see the the files in the Paco Front end.

For example when I compiled php from source I did the following :

paco -lp php5 "make install"

The parameter l makes the paco run in the log mode.This created a log file in /var/log/paco named php5 (the name I have given in the command). It contained all the files which are copied to various standard locations during the install. You could use a command line editor or paco gui to view the files.

Below is the example of getting the file list using sed command line editor
(Replace php5 with your filename).

cat /var/log/paco/php5 | sed -n 's/|\(.*\)//;/^#\(.*\)/d;p'

Once you got the list of the files, you know how to delete them don't you? Indeed, you could pass the results of the above command to rm using backticks like shown below:

sudo rm `cat /var/log/paco/php5 | sed -n 's/|\(.*\)//;/^#\(.*\)/d;p'`

Job done!

Note : Due to LD_PRELOAD limitations, paco can't follow the trace of suid programs. See man page.

2
  • 1
    checkinstall didn't work for me. paco is replaced by porg, but i was able to uninstall with porg.
    – BadK
    Feb 27, 2023 at 11:19
  • @BadK, yes porg is the preferred solution now.
    – sjsam
    Mar 11, 2023 at 11:15
2

I know of few packages that support "make uninstall" but many more that support make install DESTDIR=xxx" for staged installs.

You can use this to create a package which you install instead of installing directly from the source. I had no luck with checkinstall but fpm works very well.

This can also help you remove a package previously installed using make install. You simply force install your built package over the make installed one and then uninstall it.

For example, I used this recently to deal with protobuf-3.3.0. On RHEL7:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t rpm -n protobuf -v 3.3.0 \
 --vendor "You Not RedHat" \
 --license "Google?" \
 --description "protocol buffers" \
 --rpm-dist el7 \
 -m [email protected] \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 --rpm-autoreqprov \
 usr

 sudo rpm -i -f protobuf-3.3.0-1.el7.x86_64.rpm
 sudo rpm -e protobuf-3.3.0      

Prefer yum to rpm if you can.

On Debian9:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t deb -n protobuf -v 3.3.0 \
-C `pwd` \
--prefix / \
--vendor "You Not Debian" \
--license "$(grep Copyright ../../LICENSE)" \
--description "$(cat README.adoc)" \
--deb-upstream-changelog ../../CHANGES.txt \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 usr/local/bin \
 usr/local/lib \
 usr/local/include

 sudo apt install -f *.deb
 sudo apt-get remove protobuf

Prefer apt to dpkg where you can.

I've also posted this answer on stackoverflow

2

If you user make install and make uninstall doesn't work you can manually remove installed files.

Stop redis service:

service redis_6379 stop

Now delete everything related to Redis server from /usr/local/bin/:

rm /usr/local/bin/redis-*

Delete Redis Configuration files directory:

rm -r /etc/redis/

Delete existing Redis data directory:

rm -r /var/lib/redis/

Delete existing Redis server init scripts:

rm /etc/init.d/redis_*

Remove existing Redis PID files (Only if exists):

rm /var/run/redis_*

Restart your server and now Redis is completely removed from your Server.

2

Also if you have installed a source with traditional method, you can reinstall the package placing yourself in the same directory from where you have runned sudo make install, running sudo checkinstall. You will can then uninstall it by simply typing sudo apt-get purge $program_name

1

I had compiled php-5.6.30 from source without configuring it with openssl, so I had to go back and install it from scratch.Using make uninstall did not work as the Makefile for php doesn't support it.

However, this step worked for me, - I listed all the files related to php and removed them manually, it took me about 5 minutes without breaking a sweat. You can similarly use these steps to uninstall your compiled software.

Replace php with the software you need to uninstall

whereis php

The above command lists directories where the binaries are installed ex: /usr/local/bin/php, /usr/bin/php .. remove each file/directory listed in your output.

sudo rm -f /usr/local/bin/php

Do this with all the files listed in the above output and you are all set to install the newer version from scratch.

You must log in to answer this question.