5

I accidentally ran rm -rf /usr/local/bin. Yes, I know, I'm an idiot.

Is there anything short of attempting to run every single application on my Mac to see what applications need to be reinstalled?

1
  • 2
    I'm guessing that you don't have a recent backup ? – Kent Oct 16 '14 at 7:22
3

Most GUI Applications don't touch /usr/local/bin, so the Applications in your /Applications folder should still be in working condition. Some do install command line tools, but usually there is a menu item in the help or program menu to reinstall that command line item. Bottom line: If you don't use the command line much, you should be fine. If you use it frequently, you will see a "File not found" error when trying to run the command.

The only way to see what was in there, is indeed a backup.

1
  • I see, this is not a huge deal. As I run command line programs, if I run into an error I will just install the appropriate program. Thanks for your help. – Eric Baldwin Oct 16 '14 at 7:47
0

If you used Homebrew, this directory tells you what you have lost:

/usr/local/Cellar/

autoconf/     cloog/        hello/        libmagic/     libxml2/      p7zip/        ruby-build/   w3m/
autossh/      crystal-lang/ imagemagick/  libmpc/       libyaml/      pkg-config/   sdl/          x264/
awscli/       ffmpeg/       isl/          libpcl/       llvm/         pngcrush/     shiboken/     xvid/
bdw-gc/       freetype/     jpeg/         libpng/       mpfr/         pyside/       ssdeep/       xz/
binwalk/      gcc/          lame/         libtool/      openssl/      qt/           tree/         
brew-cask/    gmp/          libevent/     libvo-aacenc/ optipng/      rbenv/        unrar/    

To correctly execute Homebrew reinstall scripts you might also need to restart bash session if you used rbenv.

4
  • 1
    You may just run ls /usr/local/Cellar | awk '{ print $1 }' | xargs brew reinstall – alexndreazevedo Mar 28 '19 at 19:57
  • @alexndreazevedo Use brew link <name> would be better and quick – weaming May 29 '19 at 15:51
  • @weaming, good suggestion! ls /usr/local/Cellar | awk '{ print $1 }' | xargs brew link – alexndreazevedo May 30 '19 at 21:17
  • you may need to run brew unlink before brew link or else it will say it's already linked (even though it's not) – Mike Blandford Nov 7 '19 at 19:36
0

This is what worked for me to restore Homebrew installations:

ls /usr/local/Cellar | awk -F"/" '{ print $1 }' | parallel 'brew unlink {}; brew link {}; '

1
  • Where does parallel come from, don‘t think this is part of macOS? And if /usr/local/bin is lost, shouldn‘t brew itself get reinstalled first? – nohillside Dec 29 '20 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .