Skip to content

Instantly share code, notes, and snippets.

@powerumc
Last active May 7, 2024 10:57
Show Gist options
  • Save powerumc/e80bb475117582d7e842 to your computer and use it in GitHub Desktop.
Save powerumc/e80bb475117582d7e842 to your computer and use it in GitHub Desktop.
Uninstalling Mono on Mac OS X
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
for i in `ls -al | grep /Library/Frameworks/Mono.framework/ | awk '{print $9}'`; do
rm ${i}
done);
done
@clanmills
Copy link

Thank You. Very useful script.

On a clean machine (Mojave 10.14.5 + https://www.mono-project.com/download/stable/ Mono 5.18.1), I get:

198 rmills@rmillsmm-macosx:~/temp $ sudo ./foo.sh 
rm: /Library/Receipts/MonoFramework-*: No such file or directory
./foo.sh: line 7: cd: /usr/share/man/man3: No such file or directory
199 rmills@rmillsmm-macosx:~/temp $ 

Perhaps the loop should be:

for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
  if [ -e $dir ]; then
    ( cd ${dir};
      for i in `ls -al | grep /Library/Frameworks/Mono.framework/ | awk '{print $9}'`; do
        rm ${i}
      done
    ) 
  fi
done

@anton-yakovlev-mr
Copy link

@clanmills
Copy link

Thanks. I can't remember why I was interested in this. I think I had installed Visual Code for Mac and that caused me issues building something else. The pain and memory have been cleared from memory. Thanks for letting me know about this.

@king-of-poppk
Copy link

Modern instructions are simpler it seems:

sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands

@NguyenDacQuynhLoan
Copy link

@king-of-poppk thank you sir, just save my day !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment