While running
./configure --prefix=/mingw
on a MinGW/MSYS system for a library I had previously run
'./configure --prefix=/mingw && make && make install'
I came across this message:
WARNING: A version of the Vamp plugin SDK is already installed. Expect worries and sorrows if you install a new version without removing the old one first. (Continuing)
This had me worried. What's the opposite of 'make install', i.e. how is a library uninstalled in Linux? Will 'make clean' do the job, or are there other steps involved?
sudo make uninstall
if the installation configuration files are still available but no other obvious solutions if not, apart from uninstalling with system package management utility if installed with "checkinstall" utility.
make install
I've never needed make uninstall
to remove them. I've always used xargs rm < install_manifest.txt
make clean
removes any intermediate or output files from your source / build tree. However, it only affects the source / build tree; it does not touch the rest of the filesystem and so will not remove previously installed software.
If you're lucky, running make uninstall
will work. It's up to the library's authors to provide that, however; some authors provide an uninstall
target, others don't.
If you're not lucky, you'll have to manually uninstall it. Running make -n install
can be helpful, since it will show the steps that the software would take to install itself but won't actually do anything. You can then manually reverse those steps.
If sudo make uninstall
is unavailable:
In a Debian based system, instead of (or after*) doing make install
you can run sudo checkinstall
to make a .deb
file that gets automatically installed. You can then remove it using the system package manager (e.g. apt
/synaptic
/aptitude
/dpkg
). Checkinstall also supports creating other types of package, e.g. RPM.
See also http://community.linuxmint.com/tutorial/view/162 and some basic checkinstall usage and debian checkinstall package.
*: If you're reading this after having installed with make install
you can still follow the above instructions and do a dpkg -r $PACKAGE_NAME_YOU_CHOSEN
afterwards.
make install
before using checkinstall
instead.
checkinstall
for this excellent answer to work.
.deb
file without actually installing it using checkinstall --install=no
If you have a manifest
file which lists all the files that were installed with make install
you can run this command which I have from another answer:
cat install_manifest.txt | xargs echo rm | sh
If you have sudo make install
you will need to add a sudo to your uninstall:
cat install_manifest.txt | xargs echo sudo rm | sh
xargs echo rm | sh
? Quite obvious that whoever suggested this isn't particularly experienced or knowledgable in using the shell.
install_manifest.txt
contains an asterisk... rm *
will be piped into a shell.) Downvoted, for this reason.
install_manifest.txt
can be expected to exist?
Depending on how well the makefile/configure script/autofoo magic of the program in question is the following might solve your problem:
make uninstall
The problem is that you should execute this on the source tree of the version you've got installed and with exactly the same configuration that you used for installing.
How to uninstall after "make install"
Method #1 (make uninstall)
Step 1: You only need to follow this step if you've deleted/altered the build directory in any way: Download and make/make install using the exact same procedure as you did before.
Step 2: try make uninstall.
cd $SOURCE_DIR
sudo make uninstall
If this succeeds you are done. If you're paranoid you may also try the steps of "Method #3" to make sure make uninstall
didn't miss any files.
Method #2 (checkinstall -- only for debian based systems)
Overview of the process
In debian based systems (e.g. Ubuntu) you can create a .deb
package very easily by using a tool named checkinstall
. You then install the .deb package (this will make your debian system realize that the all parts of your package have been indeed installed) and finally uninstall it to let your package manager properly cleanup your system.
Step by step
sudo apt-get -y install checkinstall
cd $SOURCE_DIR
sudo checkinstall
At this point checkinstall
will prompt for a package name. Enter something a bit descriptive and note it because you'll use it in a minute. It will also prompt for a few more data that you can ignore. If it complains about the version not been acceptable just enter something reasonable like 1.0
. When it completes you can install and finally uninstall:
sudo dpkg -i $PACKAGE_NAME_YOU_ENTERED
sudo dpkg -r $PACKAGE_NAME_YOU_ENTERED
Method #3 (install_manifest.txt)
If a file install_manifest.txt
exists in your source dir it should contain the filenames of every single file that the installation created.
So first check the list of files and their mod-time:
cd $SOURCE_DIR
sudo xargs -I{} stat -c "%z %n" "{}" < install_manifest.txt
You should get zero errors and the mod-times of the listed files should be on or after the installation time. If all is OK you can delete them in one go:
cd $SOURCE_DIR
mkdir deleted-by-uninstall
sudo xargs -I{} mv -t deleted-by-uninstall "{}" < install_manifest.txt
User Merlyn Morgan-Graham however has a serious notice regarding this method that you should keep in mind (copied here verbatim): "Watch out for files that might also have been installed by other packages. Simply deleting these files [...] could break the other packages.". That's the reason that we've created the deleted-by-uninstall
dir and moved files there instead of deleting them.
99% of this post existed in other answers. I just collected everything useful in a (hopefully) easy to follow how-to and tried to give extra attention to important details (like quoting xarg arguments and keeping backups of deleted files).
make clean
generally only cleans built files in the directory containing the source code itself, and rarely touches any installed software.
Makefiles generally don't contain a target for uninstallation -- you usually have to do that yourself, by removing the files from the directory into which they were installed. For example, if you built a program and installed it (using make install
) into /usr/local
, you'd want to look through /usr/local/bin
, /usr/local/libexec
, /usr/local/share/man
, etc., and remove the unwanted files. Sometimes a Makefile includes an uninstall
target, but not always.
Of course, typically on a Linux system you install software using a package manager, which is capable of uninstalling software "automagically".
The "stow" utility was designed to solve this problem: http://www.gnu.org/software/stow/
stow
to solve this problem?
There is no standard unfortunately, this is one of the perils of installing from source. Some Makefiles will include an "uninstall", so
make uninstall
from the source directory may work. Otherwise, it may be a matter of manually undoing whatever the make install
did.
make clean
usually just cleans up the source directory - removing generated/compiled files and the like, probably not what you're after.
Make
Make is the program that’s used to install the program that’s compiled from the source code. It’s not the Linux package manager so it doesn’t keep track of the files it installs. This makes it difficult to uninstall the files afterward.
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 the 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 Linux package manager which allows it to be uninstalled like any regular package.
The CheckInstall command is used to call 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" with your information from the Screenshot.
Execute the following commands in the source package directory:
Install CheckInstall sudo apt-get install checkinstall Run the Configure script sudo ./configure Run the Make command sudo make Run CheckInstall sudo checkinstall Reinstall the package sudo dpkg --install --force-overwrite source_location.deb Remove the package sudo apt remove name
Here's an article article I wrote that covers the whole process with explanations.
Method 1
From the source folder:
#make uninstall
Method 2
If there is no uninstall procedure:
open install_manifest.txt (created by #make install) remove all the directories/files listed remove any remaining files you missed: #xargs rm < install_manifest.txt remove any hidden directories/files: $rm -rf ~/.packagename
Remove the source folder.
Method 3
If none of the above options work, view the install procedure:
#make -n install
and reverse the install procedure:
#rm -rf all directories/files created
Example
For example, this is how to uninstall nodejs, npm, and nvm from source:
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
which you can do using any of the above methods.
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 you@youraddress.com \
--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 answer this here
Make
can tell you what it knows and what it will do. Suppose you have an "install" target, which executes commands like:
cp <filelist> <destdir>/
In your generic rules, add:
uninstall :; MAKEFLAGS= ${MAKE} -j1 -spinf $(word 1,${MAKEFILE_LIST}) install \
| awk '/^cp /{dest=$NF; for (i=NF; --i>0;) {print dest"/"$i}}' \
| xargs rm -f
A similar trick can do a generic make clean
.
Preamble
below may work or may not, this is all given as-is, you and only you are responsible person in case of some damage, data loss and so on. But I hope things go smooth!
To undo make install
I would do (and I did) this:
Idea: check whatever script installs and undo this with simple bash script.
Reconfigure your build dir to install to some custom dir. I usually do this: --prefix=$PWD/install. For CMake, you can go to your build dir, open CMakeCache.txt, and fix CMAKE_INSTALL_PREFIX value. Install project to custom directory (just run make install again). Now we push from assumption, that make install script installs into custom dir just same contents you want to remove from somewhere else (usually /usr/local). So, we need a script. 3.1. Script should compare custom dir, with dir you want clean. I use this:
anti-install.sh
RM_DIR=$1
PRESENT_DIR=$2
echo "Remove files from $RM_DIR, which are present in $PRESENT_DIR"
pushd $RM_DIR
for fn in `find . -iname '*'`; do
# echo "Checking $PRESENT_DIR/$fn..."
if test -f "$PRESENT_DIR/$fn"; then
# First try this, and check whether things go plain
echo "rm $RM_DIR/$fn"
# Then uncomment this, (but, check twice it works good to you).
# rm $RM_DIR/$fn
fi
done
popd
3.2. Now just run this script (it will go dry-run)
bash anti-install.sh <dir you want to clean> <custom installation dir>
E.g. You wan't to clean /usr/local, and your custom installation dir is /user/me/llvm.build/install, then it would be
bash anti-install.sh /usr/local /user/me/llvm.build/install
3.3. Check log carefully, if commands are good to you, uncomment rm $RM_DIR/$fn
and run it again. But stop! Did you really check carefully? May be check again?
Source to instructions: https://dyatkovskiy.com/2019/11/26/anti-make-install/
Good luck!
Success story sharing