Skip to content

Instantly share code, notes, and snippets.

@ryangatchalian912
Last active September 16, 2021 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryangatchalian912/b87813937d47b75c922e825177f83a61 to your computer and use it in GitHub Desktop.
Save ryangatchalian912/b87813937d47b75c922e825177f83a61 to your computer and use it in GitHub Desktop.
Mac OS X uninstall script for packaged install of R for Mac OS X
#!/bin/bash
(( ${#} >= 0 )) || {
echo 'DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!'
echo 'THE AUTHOR TAKES NO RESPONSIBILITY FOR THE RESULTS OF THIS SCRIPT.'
echo "Disclaimer aside, this worked for the author, for what that's worth."
echo 'Press Control-C to quit now.'
read
echo 'Re-running the script with sudo.'
echo 'You may be prompted for a password.'
sudo ${0} sudo
exit $?
}
# This will need to be executed as an Admin (maybe just use sudo).
# Verify that core R package bom exists. Otherwise, don't do anything.
[ -e /var/db/receipts/org.R-project.R.fw.pkg.bom ] || {
echo '>>> Core R package not found. Nothing to do.'
exit 0
}
# Loop through all the files in the bom.
echo '>>> Removing bom files from org.R-project.R.fw.pkg.bom...'
lsbom -f -l -s -pf /var/db/receipts/org.R-project.R.fw.pkg.bom \
| while read i; do
# Remove each file listed in the bom.
rm -v /Library/Frameworks/${i#./}
done
# Verify that R GUI package bom exists. Otherwise, don't do anything.
[ -e /var/db/receipts/org.R-project.R.GUI.pkg.bom ] || {
echo '>>> R GUI package not found. Nothing to do.'
exit 0
}
# Loop through all the files in the bom.
echo '>>> Removing bom files from org.R-project.R.GUI.pkg.bom...'
lsbom -f -l -s -pf /var/db/receipts/org.R-project.R.GUI.pkg.bom \
| while read i; do
# Remove each file listed in the bom.
rm -v "/Applications/${i#./}"
done
# Verify that Tcl/tk for R package bom exists. Otherwise, don't do anything.
[ -e /var/db/receipts/org.r-project.x86_64.tcltk.bom ] || {
echo '>>> Tcl/tk for R package not found. Nothing to do.'
exit 0
}
# Loop through all the files in the bom.
echo '>>> Removing bom files from org.r-project.x86_64.tcltk.bom...'
lsbom -f -l -s -pf /var/db/receipts/org.r-project.x86_64.tcltk.bom \
| while read i; do
# Remove each file listed in the bom.
rm -v /${i#./}
done
# Verify that Texinfo for R package bom exists. Otherwise, don't do anything.
[ -e /var/db/receipts/org.r-project.x86_64.texinfo.bom ] || {
echo '>>> Texinfo for R package not found. Nothing to do.'
exit 0
}
# Loop through all the files in the bom.
echo '>>> Removing bom files from org.r-project.x86_64.texinfo.bom...'
lsbom -f -l -s -pf /var/db/receipts/org.r-project.x86_64.texinfo.bom \
| while read i; do
# Remove each file listed in the bom.
rm -v /${i#./}
done
# Remove files and directories related to R for Mac OSX.
echo '>>> Removing R for Mac OSX files and directories...'
sudo rm -rf /Library/Frameworks/R.framework \
/usr/local/lib/itcl* \
/usr/local/lib/sqlite* \
/usr/local/lib/thread* \
/usr/local/lib/tcl* \
/usr/local/lib/tdbc* \
/usr/local/lib/tk* \
/usr/local/lib/Tk* \
/usr/local/share/texinfo \
/usr/local/bin/{makeinfo,R,Rscript} \
/private/var/folders/h_/y0zznsx52311nbq4t46y3chm0000gn/C/org.R-project.R \
~/Library/Saved\ Application\ State/org.R-project.R.savedState \
~/Library/Preferences/org.R-project.R.plist \
~/.r \
~/.Rapp.history \
~/.RData \
~/.Rhistory \
/var/db/receipts/org.R-project.R.* \
/var/db/receipts/org.r-project.x86_64.*
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment