Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reinstalling homebrew symbolic links after a restore

Tags:

macos

homebrew

I restored my Mac running 10.9 from time machine after a re-install but it appears that the symbolic links under /usr/local/bin for some of the formulas were lost. The formulas are still installed according to brew list $formula but without the links from /usr/local/bin.

(e.g. /usr/local/Cellar/findutils/4.4.2/bin/gfind exists but not /usr/local/bin/gfind).

Is there a "proper" brew-way to reinstate the links from /usr/local/bin or should I just run a simple find.. | xargs ln -s ...?

There are quite a few links under /usr/local/bin for other formulas, perhaps because I executed brew upgrade, but not to all of them.

like image 676
Amos Shapira Avatar asked Apr 13 '14 02:04

Amos Shapira


People also ask

What does Brew update reset do?

The update-reset version of this command resets all formulae to be identical to the contents of their remote repositories, deleting any local changes. It is only used as a last-resort effort to fix a problem (it's like unplugging Homebrew and plugging it back in).

How do I remove a broken symbolic link Mac?

Remove a Symbolic Link with unlink The best way to remove a symlink is with the appropriately named “unlink” tool. Using unlink to delete a symlink is extremely simple, you just need to point it at the symbolic link to unlink and remove. As always with the command line, be sure your syntax is precise.


1 Answers

Instead of reinstating the symlinks, the better way to do it would be to use brew link.

For a given binary which isn't in /usr/local/bin, e.g. yasm, run brew unlink yasm && brew link yasm.

You can run this for all of your packages using xargs, like so:

brew list | xargs -I % sh -c 'brew unlink %; brew link %'

like image 160
jaynp Avatar answered Oct 13 '22 18:10

jaynp