MacOS – Why can’t I use .app bundles symlinked into /Applications as default in the ‘open with’ dialog

applicationsemacshomebrewmacossymlink

I have installed emacs with homebrew, with the --cocoa flag, which makes homebrew create an .app bundle in /usr/local/Cellar/emacs/<version>/Emacs.app. I have symlinked the .app bundle into /Applications/, to make it easy to open. The problem is that when I try setting file associations for files, I can't set Emacs.app as the default (the Add button is greyed out):

Unable to select open with emacs

Now I could just copy or move the .app bundle into /Applications/, but that would require me to copy it over again every time emacs is updated via homebrew. Is there some other way to solve this?

Best Answer

I don't know why, but I have figured it out that if I make the symlink to the Contents directory, then associations work fine.

That is I do the following in a terminal window, using my personal Applications folder as an example:

% mkdir ~/Applications/Emacs.app
% ln -s /usr/local/Cellar/emacs/23.2/Emacs.app/Contents ~/Applications/Emacs.app

Something about putting the symlink inside the Emacs.app gets the bundle recognized.