How to uninstall gcc installed from source? - linux

How can I uninstall a gcc build which I installed from source.I am using gcc 4.9 and I'm on ubuntu 12.04.
Or is there a way to upgrade to latest gcc versions through the ubuntu repository?

When you build a package from source there is unfortunately no magic uninstall usually, however you can approximate this, credit to this mailing list thread.
Basically you should install again into a temporary directory and list all the files created in said directory, then you can delete all of them from the main system through a script.
Here is an example of a script to uninstall GCC in this way:
make install DESTDIR=/tmp/gccinst
find /tmp/gccinst | sed -e s,/tmp/gccinst,, | \
(while read F; do rm "$F"; done)
Run it from inside the gcc source directory as root.
To answer your second question you can install the latest gcc available in the ubuntu repo with:
apt-get install gcc
Overlay repos may have newer versions, I have seen a suggestion there is a newer version at ubuntu-toolchain-r/test (install via):
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
But I am not sure if they have added 4.9 there yet. If not you will indeed have to install from source.
EDIT:
It looks like #roelofs found a better guide to install the repo in his answer, so go look there too and remember to give him an upvote if it helps :)

In GCC 5.1.0, although there is no top-level uninstall target, some directories do have it, in particular gcc, so you can do:
cd build/gcc
sudo make uninstall
This does not remove everything that was installed, but it removes major executables like gcc, g++, cpp... contained in that directory, so it might be enough.

Vality has a great start
make install DESTDIR=/tmp/gccinst
But his cleanup command has a few problems. First, it passes directories to rm, including the usual directories (such as /usr). We can fix this via -type f:
find /tmp/gccinst -type f | sed -e s,/tmp/gccinst,, | \
(while read F; do rm "$F"; done)
Getting rid of the directories that this leaves empty...
find /tmp/gccinst -depth -type d -not -empty | sed -e s,/tmp/gccinst,, | \
(while read F; do rmdir -p --ignore-fail-on-non-empty "$F"; done)

add to Vality and Ben. If you do this from your own login shell:
find $HOME/tmp/gccinst/ -type f | sed -e s,$HOME/tmp/gccinst,, | (while read F; do rm **-f** "$F" ; done)
Need -f flag or the script may not run if there's some permission issue.

/root/ihome3/gcc-4.6.3/gcc-build-4.6.3/gcc
[root#izwz93atpyz gcc]# make uninstall
rm -rf /usr/local/bin/c++
rm -rf /usr/local/bin/g++
rm -rf /usr/local/share/man/man1/g++.1
rm -rf /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3
rm -rf /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.3
rm -rf /usr/local/bin/gcc
rm -f /usr/local/bin/cpp
if [ x != x ]; then \
rm -f /usr/local//cpp; \
else true; fi
rm -rf /usr/local/bin/gcov`enter code here`
rm -rf /usr/local/share/man/man1/gcc.1
rm -rf /usr/local/share/man/man1/cpp.1
rm -f /usr/local/share/info/cpp.info* /usr/local/share/info/gcc.info*
rm -f /usr/local/share/info/cppinternals.info* /usr/local/share/info/gccint.info*
[root#izwz93atpalb56zydy9bpyz gcc]# pwd
/root/ihome3/gcc-4.6.3/gcc-build-4.6.3/gcc

the following operation isreally ok. when you make one gcc from source code and make install at gcc-build,then it will generaton one gcc direction at source code's top direction. cd $source_code_top/gcc , then make uninstall. it will purge remove gcc from you linux system.

The highest available version of GCC in the 12.04 repositories is 4.6. You can use the package manager to install a newer version, but you will have to add a PPA. This link should help, although it is for a slightly older version of GCC (but can be used for the newest version).
As a commenter pointed out, if your own built version of GCC was compiled with the --prefix parameter, the entire installation should be in that directory under /usr/local or wherever you installed it, and can be removed.

Related

How can I compile and install Emacs in the home directory?

I want to install Emacs without using APT/YUM, because I am not a super user.
I downloaded the source code from
https://www.gnu.org/software/emacs/manual/html_node/efaq/Installing-Emacs.html. Then, I commanded
./configure --prefix=$HOME/.local/emacs/27_1
Standard output said
configure: error: The following required libraries were not found:
gnutls
Maybe some development libraries/packages are missing?
To build anyway, give:
--with-gnutls=ifavailable
as options to configure.
So I commanded
./configure --with-gnutls=ifavailable --prefix=$HOME/.local/emacs/27_1
Standard output said
configure: error: The required function 'tputs' was not found in any library.
The following libraries were tried (in order):
libtinfo, libncurses, libterminfo, libcurses, libtermcap
Please try installing whichever of these libraries is most appropriate
for your system, together with its header files.
For example, a libncurses-dev(el) or similar package.
So I downloaded ncurses and installed it by:
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz
tar xvfz ncurses-6.2.tar.gz
cd ncurses-6.2
./configure --prefix=$HOME/.local/ncurses/6_2 --with-shared --with-pkg-config-libdir=$HOME/ncurses/6_2/lib/pkgconfig --enable-pc-files
make
make install
And I made symbolic links and PATH
cd ~/.local/bin
ls ../ncurses/6_2/bin/ | xargs -I {} ln -s ../ncurses/6_2/bin/{} {}
cd ~/.local/include
ls ../ncurses/6_2/include/ | xargs -I {} ln -s ../ncurses/6_2/include/{} {}
cd ~/.local/lib
ls ../ncurses/6_2/lib/ | xargs -I {} ln -s ../ncurses/6_2/lib/{} {}
cd ~/.local/lib/pkgconfig
ls ../../ncurses/6_2/lib/pkgconfig/ | xargs -I {} ln -s ../../ncurses/6_2/lib/pkgconfig/{} {}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/.local/lib/pkgconfig
I did configure again, but the same error occurred. What should I do?

How i can remove ghdl 0.29 from Debian?

I follow this steps to install GHDL compiler in my Debian, but now I need to uninstall this compiler to install x64 version, and I can't.
By downloading the binaries and unpacking them manually:
$ wget http://ghdl.free.fr/site/uploads/Main/ghdl-i686-linux-latest.tar
$ sudo tar xvf ghdl-i686-linux-latest.tar
(This generates the file ghdl-0.29-i686-pc-linux.tar.bz2)
$ cd ghdl-0.29-i686-pc-linux
$ sudo tar -C / -jxvf ghdl-0.29-i686-pc-linux.tar.bz2
(This copy the files to /usr/local/bin and /usr/local/lib)
I have used dpkg --purge ghdl, but if I use ghdl --version, the ghdl 0.29 still in the system.
How can I remove it?
faced the same situation and this is how i did it:
goto where your tarball is and use this command
sudo tar -tf ghdl-0.29-i686-pc-linux.tar.bz2 | sed 's/^..//' | parallel sudo rm -rf
explanation:
tar -tf ghdl-0.29-i686-pc-linux.tar.bz2 List all files in archive.tar
sed 's/^..//' Removes initial directory characters
parallel sudo rm -rf removes matching files
this will leave some empty directories at /usr/local and if you want to get rid of them you can use
sudo find /usr/local/* -type d -empty -delete

mv command not working - Error: no package mv available

run the mv command but nothing happened so I tried to install it:
# yum install mv
then i got the Nothing to do response with error : no package mv available
Any pointers on how to set up the mv command in Apache 2.2.15 on Centos 6.
Thank you very much in advance
N.B The last 3 lines after issuing the yum install mv:
Setting up Install Process
No package mv available.
Error: Nothing to do
Please explain nothing happened.
mv belongs to the coreutils. If you don't have mv installed then your system is seriously broken. But I'm very sure you have mv installed, otherwise you would see an error message like mv: command not found.
If there is no error, then mv won't print any output at all. This is the intended behavior. If you want to force output, then append the argument -v for verbose mode.
You can use the type command to see if your mv has been incorrectly aliased to something else.
Mine is:
$ type mv
mv is /bin/mv
Yours may be something like
$ type mv
mv is an alias for
You can use the unalias command to correct this type of problem.
$ unalias mv

How do I uninstall nodejs installed from pkg (Mac OS X)?

I installed NodeJS from pkg file on my Mac. Now I need to uninstall it. Tell me please how to do it.
I tried to remove files from this list:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom
But node is still on my computer.
I ran:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
sudo rm /usr/local/${i}
done
sudo rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
Coded into gist 2697848
Update
It seems the receipts .bom file name may have changed so you may need to replace org.nodejs.pkg.bom with org.nodejs.node.pkg.bom in the above. The gist has been updated accordingly.
If you installed Node from their website, try this:
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
This worked for me, but if you have any questions, my GitHub is 'mnafricano'.
Following previous posts, here is the full list I used
sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
brew install node
In order to delete the 'native' node.js installation, I have used the method suggested in previous answers sudo npm uninstall npm -g, with additional sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*.
BUT, I had to also delete the following two directories:
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
Only after that I could install node.js with Homebrew.
You can use my forked gist:
https://gist.github.com/ryangatchalian912/75c6894c3f3143fef366d25eb63437ab
Copy and paste these commands into your Terminal:
curl -ksO https://gist.githubusercontent.com/ryangatchalian912/75c6894c3f3143fef366d25eb63437ab/raw/59c25be64e5555415726bfa824ae41ae1b4539b9/uninstall-node.sh
chmod +x ./uninstall-node.sh
sudo ./uninstall-node.sh > tester.txt
rm uninstall-node.sh
It works on Mac OSX Big Sur (11.4+).
This is the full list of commands I used (Many thanks to the posters above):
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
brew install node
Use npm to uninstall. Just running sudo npm uninstall npm -g removes all the files.
To get rid of the extraneous stuff like bash pathnames run this (from nicerobot's answer):
sudo rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
I took AhrB's list, while appended three more files. Here is the full list I have used:
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/bin/npm
sudo rm /usr/local/share/systemtap/tapset/node.stp
sudo rm /usr/local/lib/dtrace/node.d
# In case you want to reinstall node with HomeBrew:
# brew install node
A little convenience script expanding on previous answers.
#!/bin/bash
# Uninstall node.js
#
# Options:
#
# -d Actually delete files, otherwise the script just _prints_ a command to delete.
# -p Installation prefix. Default /usr/local
# -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom
CMD="echo sudo rm -fr"
BOM_FILE="/var/db/receipts/org.nodejs.pkg.bom"
PREFIX="/usr/local"
while getopts "dp:f:" arg; do
case $arg in
d)
CMD="sudo rm -fr"
;;
p)
PREFIX=$arg
;;
f)
BOM_FILE=$arg
;;
esac
done
lsbom -f -l -s -pf ${BOM_FILE} \
| while read i; do
$CMD ${PREFIX}/${i}
done
$CMD ${PREFIX}/lib/node \
${PREFIX}/lib/node_modules \
${BOM_FILE}
Save it to file and run with:
# bash filename.sh
A decent way to uninstall node installed from pkg
See what is in db/receipts
ls /var/db/receipts/org.node*
Peek into the relevant bom files noting the paths listed
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.npm.pkg.bom
Do the deletes. Use prefix on remove depending on the paths above.
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read i; do sudo rm /${i}; done
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.npm.pkg.bom | while read i; do sudo rm /${i}; done
Remove the remaining folders
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /var/db/receipts/org.nodejs.*
Check it is really gone
which node
which npm
I had to remove the following files too since brew complained in install later after manually removing all files.
/usr/local/share/doc/node/gdbinit
/usr/local/share/systemtap/tapset/node.stp
and then do the following
brew install node
brew link node
The following worked after trial and error, and these directories were not writable so, I removed them and finally was able to get node & npm replaced.
sudo rm -rf /usr/local/share/systemtap
sudo rm -rf /usr/local/share/doc/node
sudo rm -rf /usr/local/Cellar/node/9.11.1
brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-9.11.1.high_sierra.bottle.tar.gz
Already downloaded: /Users/xxx/Library/Caches/Homebrew/node-9.11.1.high_sierra.bottle.tar.gz
==> Pouring node-9.11.1.high_sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/9.11.1: 5,125 files, 49.7MB
node -v
v9.11.1
npm -v
5.6.0

Everywhere that GHC/Haskell Platform installs

Assume I want to completely reinstall GHC/HP. I want to (as much for superstition as anything) delete anything and everything from previous installs. What do I actually need to delete (and where)?
Edit: I'm on OSX, but I'm more curious if this information is available in general, for all systems.
Edit2: So far we have:
OSX:
/Library/Frameworks/GHC.framework/
~/.cabal/
/usr/bin/ -- symlinks
I'll add to that (based on "prefix" defined here: http://www.vex.net/~trebla/haskell/sicp.xhtml#storage):
prefix/lib/
prefix/share/
prefix/bin/
prefix/share/doc/
/usr (/local) /lib/[ghc-version]
/usr (/local) /share/doc/ghc/html/libraries/ -- documentation
/usr (/local) /share/doc/ghc/
/usr (/local) /bin
/var/lib/[ghc-version]
/etc/[ghc-version]
~/.ghc/
Edit 3:
OS X:
~/Library/Haskell
Linux:
??
Windows:
??
Had to remove Haskell Platform on OS X recently. Most are cleaned up via Uninstaller:
sudo /Library/Frameworks/GHC.framework/Versions/Current/Tools/Uninstaller
These have to be cleaned up manually:
rm -r ~/.cabal
rm -r ~/.ghc
rm -r ~/Library/Haskell
Alternatively, as documented in
/Library/Haskell/doc/start.html
there is now a custom uninstall command with options,
/Library/Haskell/bin/uninstall-hs
In general, one can document the files created by any activity (installer, ...) by bracketing the activity in a work directory with
echo >timestamp
[activity]
sudo find -x / -newer timestamp -print >snapshot.txt
If you've installed a Haskell Platform since about 2012 on OS X, just run
uninstall-hs
and carefully read what it outputs. You'll need to run it again with the options it offers you. Run
uninstall-hs --help
for more options.
Below is my original answer, which will still work, but doesn't offer as many options and is a bit "ham fisted":
Warning: This script is extreme. It will remove even your custom config files for GHC and Cabal, and executables you've built that are still in ~/Library/Haskell or ~/.cabal. Use caution; review what it is about to do; have backups; caveat scriptor!
#!/bin/bash
set -x
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf ~/.cabal
rm -rf ~/.ghc
rm -rf ~/Library/Haskell
find /usr/bin /usr/local/bin -type l | \
xargs -If sh -c '/bin/echo -n f /; readlink f' | \
egrep '//Library/(Haskell|Frameworks/(GHC|HaskellPlatform).framework)' | \
cut -f 1 -d ' ' > /tmp/hs-bin-links
sudo rm -f `cat /tmp/hs-bin-links`
You may want to add lines to save off and restore your config files like:
mv ~/.cabal/config /tmp/cabal-config 2>/dev/null || true
mv ~/.ghc/gchi.conf /tmp/ghci-config 2>/dev/null || true
and
mkdir ~/.cabal
mkdir ~/.ghc
cp /tmp/cabal-config ~/.cabal/config 2>/dev/null || true
cp /tmp/ghci-config ~/.ghc/gchi.conf 2>/dev/null || true
Bracket the rm lines with these. Though you may or may not want your old ~/.cabal/config if you are upgrading to newer stuff.
Note that this only deals with the current user's home directory. If you have multiple user accounts that all use Haskell, then the other accounts will need cleaning as well. (Repeat the lines involving ~.)
I am on OSX (Lion atm). I've got GHC in /Library/Frameworks/GHC.framework/ (current and previous versions). There are also some symlinks in /usr/bin, but these will be replaced by a new install.
If you have used cabal to (locally) install packages, you also may want to clean out ~/.cabal. If you have a recent cabal, you can easily reinstall all packages for the 'new' GHC version by using cabal install world and then look for directories matching previous version of GHC you had like so:
for package in `ls ~/.cabal/lib/`; do
if [ ! -d ~/.cabal/lib/${package}/ghc-7.0.3 ]; then
echo $package;
else
echo "OK for $package";
fi;
done
These should be safe to delete.
Hope this helps you somewhat.
uninstall-hs does some of the work for you; I'm not sure how much.

Resources