Converting pre-installed apps/packages to Homebrew
I really like Homebrew. However, I consistently run into an issue with things that I installed before I learned of the magical OS X package manager.
What I get is this:
Error: The linking step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using `brew link [name]'
which of course fails too. Maybe I'm missing something—and I feel like this question has to have been asked somewhere, but I couldn't find it. Uninstalling the Homebrew version of the app, then running brew link on it also fails (as there's no keg in /usr/local/Cellar).
Is this an issue with the formula writers and not Homebrew itself? It seems that much of the kind of software offered through Homebrew also isn't the kind with a simple uninstall process, which might be part of the issue.
I have been able to get some to work by just removing the files put in place by the initial (pre-Homebrew) installation. It's just very time-consuming and I'm hoping there's something a little more automatic.
(You obviously can't "convert pre-installed apps/packages to Homebrew" as your title suggests; you have to remove them and install the brew replacements. Given the text of your question, you clearly already know this, so I'm not saying this to be patronizing or anything, just in case other readers are confused.)
There really is nothing automatic to do what you want. And if you think about it, there really couldn't be—if you installed something without a package manager, there's no record of what was part of the install, so no way to automatically uninstall it.
In some cases, you can just cd into the source and "make uninstall". In other cases, you can look at the contents of what brew would install and assume that your pre-brew install created the exact same set of files. (And you could even automate that with a script, I suppose.) The install will at least tell you why it failed, and therefore which files you have to remove (which you could also automate with a script—although if you only remove exactly those files you'll often leave behind lots of config/etc. info).
But regardless, if you want brew and non-brew stuff to share /usr/local (which generally works, and seems to be officially recommended), you have to deal with conflicts manually, as they come up.
See the FAQ (if you haven't already) for further information.
If you want to save yourself the pain, there are a few ways to do that. Here are the choices:
Wipe out everything in /usr/local, reinstall brew, and reinstall everything you need (ideally with Homebrew versions—and you can usually create your own formulas very easily if they don't exist). You may want to back up the old /usr/local, just in case you later discover your "everything you need" was incomplete… This is obviously the cleanest solution, but it means repeating work you've already done.
Rename /usr/local to something like /opt/oldusrlocal, put that on your path after /usr/local, and let Homebrew manage /usr/local completely. This may break a few packages that store absolute paths during build/install, which means you'll have to rebuild them (which is a good opportunity to switch to the brew versions), and it seems pretty hacky, but it works pretty well.
Rename /usr/local as above, don't put it in your path, and manually symlink stuff into /usr/local as you discover you need it.
Install brew somewhere besides /usr/local (and put that on your path ahead of /usr/local). There are a few formulas (and outside egss/gems/etc.) that don't work right that way (since nearly everyone tests against /usr/local), as the Homebrew FAQ explains, but it is doable.