Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OSX Mavericks Upgrade Clears /usr/local/bin

I had been holding off on upgrading to Mavericks for fear that it would break thinks and it seems my fears came true. I had a stock Homebrew install with lots of compiled tools linked to /usr/local/bin and some custom links to other binaries, for example a shortcut for Sublime Text. After upgrading to Mavericks, the folder was cleared of almost everything, and therefore none of the commands work. The brew script remained, and some latex tools but that appears to be it.

Is this an expected behavior upon the upgrade and is there any quick fix for it? Can I just copy the folder contents from a backup? Is the only way to unlink & re-link everything manually in Homebrew (this doesn't address things I lost that were not compiled through Homebrew)?

I just noticed that /usr/local/lib seems to have suffered a similar fate, if that matters to any answers. I'm worried what else might have been affected.

like image 423
Damian Avatar asked Mar 20 '14 23:03

Damian


People also ask

Does upgrading macOS delete files?

Will updating macOS erase files? Short answer: No. Upgrading should not pose any risks to your data.

Can I upgrade my Mac from Mavericks?

Make sure you're ready to upgrade. Then, if your Mac is running OS X Mavericks 10.9 or later, you can upgrade directly to macOS Catalina.

Does macOS use usr local?

More specifically, /usr/lib is for macOS installed shared libraries. Anything under /usr/local are user-installed. So /usr/local/lib contains shared libraries installed by you.

Can I delete usr local Mac?

In OS X, /usr/local isn't used for anything by default. You can safely remove it if you know what's in there and do not depend on anything, e.g. Homebrew, which is probably the most popular use for /usr/local in OS X.


1 Answers

I've copied and pasted my answer verbatim from the Apple Stackexchange question since the link to the relevant question is buried in the comments.

First, relink all the installed formulas you can:

brew list -1 | while read line; do brew unlink $line; brew link --force $line; done

Then run brew doctor, which should complain and give you two lists:

  • Unlinked formulae with multiple versions
  • Keg-only formulae which have been incorrectly link by the original relinking process.

For each formula with multiple versions run the following, replacing "python" with the formula name:

brew info python  

This will show you, among other information, all installed versions. Choose which version you want to link (for me its 2.7.6), and use brew switch

brew switch python 2.7.6

You will also want to run brew unlink on the list (if any) of keg-only formulae that have been linked.

like image 84
Scott Ritchie Avatar answered Sep 21 '22 15:09

Scott Ritchie