12

After upgrading to macOS Catalina, Emacs (v26.3 from GNU Emacs for Mac OS X) works very strange. Without Emacs already running, Finder can open a file with Emacs as usual. But once Emacs.app is running, it cannot any longer. For example, double clicking the file on Finder window does nothing; no error message, either.

Opening a file from Emacs GUI causes no problem. Drag-ang-drop'ing a file onto Emacs also works fine.

5
  • I suggest you take a look (within Emacs) at C-h l after such "failed" operations to see if Emacs received some event at all. If not, the problem likely can't be solved on Emacs's side and you should post your question elsewhere.
    – Stefan
    Oct 20, 2019 at 14:11
  • You're right. Looks like Emacs doesn't get any event call. But, is it not Emacs issue? I thought it's a matter of building Emacs. (By the way, I installed Emacs with Homebrew). Where would it suit better? Homebrew? Oct 21, 2019 at 4:04
  • sorry, but my outlook on this is along the lines of "why don't you upgrade to GNU/Linux?", which probably won't help you very much. You can file a bug report with M-x report-emacs-bug.
    – Stefan
    Oct 21, 2019 at 13:06
  • I see. Thanks for your remarks and suggestions anyhow. Oct 22, 2019 at 6:22
  • I thought this answer would be responsive, but I tried the steps and it didn't work.
    – HaPsantran
    Nov 25, 2019 at 16:07

4 Answers 4

1

This is the current solution that I came out with: use emacsclient and wrap it in an application.

First, put this line in ~/.emacs:

(server-start)

Create this bash script:

if ! pgrep Emacs; then
    open -a Emacs.app
    sleep 1
fi
for f in "$@"
do
    /usr/local/bin/emacsclient -c -n "$f"
done

Note: Make sure that your emacsclient path is correct.

Then create a wrapper application using this method: https://superuser.com/a/239235

But remember to change Shell to /bin/bash.

8
  • Thanks for the temporary solution, which unfortunately is a bit limited in my workflow. I hope the ultimate solution comes soon with the next release of Eamcs. Oct 28, 2019 at 0:04
  • @MassoChailly With the wrapper application, you can double click multiple files in Finder to Open all of them in Emacs, just like how it used to work.
    – Lawrence
    Oct 30, 2019 at 2:45
  • Oh, right! Thanks! Oct 31, 2019 at 6:56
  • Thanks, this looks helpful, and I've created both the shell script (exactly as above after confirming emacsclient path) and the automator script (exactly as the growl example but using the path of the aforementioned bash script instead), but it's unclear to me how running emacs myfile.py from the command line invokes the automator script. Can you please clarify?
    – HaPsantran
    Apr 22, 2020 at 11:30
  • @HaPsantran This method creates a graphical application, say XXX.app. From the command line, you could perform open -a XXX myfile.py
    – Lawrence
    Apr 24, 2020 at 8:51
12

If your Emacs is downloaded from https://emacsformacosx.com/, Emacs.app launches a binary Emacs.app/Contents/MacOS/Emacs-x86_64-10_14 via a ruby script Emacs.app/Contents/MacOS/Emacs. Modify Emacs.app to launch a binary directly with the following in terminal.

cd /Applications/Emacs.app/Contents/MacOS
mv Emacs Emacs-orig
ln -s Emacs-x86_64-10_9 Emacs
rm bin
ln -s bin-x86_64-10_9 bin
rm libexec
ln -s libexec-x86_64-10_9 libexec

Edit by Masso: Emacs-x86_64-10_14 breaks forward search (from Emacs to Skim) on macOS 10.15 (Catalina). So I have changed the version numbers above to 10_9 (instead of 10_14 that was originally suggested by Akira). Edit by acr: the rm'd directory should be libexec.

NOTE: For macOS Catalina 10.15.7 Emacs 27.1 (9) I needed to use _14. My install was already linked to _10 and having the permission problem. I made these changes after updating Security & Privacy settings giving Full Disk Access to Emacs.app. I installed emacs via brew and noticed the problem after recently upgrading on 12/20/20. The older version didn't have the problem AFAIK and I had previously applied the fix detailed here. I'm not using Emacs Skim and not familiar with the problems mentioned by Masso and I want the latest Emacs version. Setting to _14 worked for me:

% cd /Applications/Emacs.app/Contents/MacOS
% mv Emacs Emacs-orig
% ln -s Emacs-x86_64-10_14 Emacs

% rm bin
% ln -s bin-x86_64-10_14 bin

% rm libexec
% ln -s libexec-x86_64-10_14 libexec
8
  • * I wanted to add a comment for Akira Kitauchi, but I don't have enough (50) reputations to do it. Hence I put it here. Akira's solution is interesting and does work for me. However, the so-called "forward search" from Emacs (working with a LaTeX file) to Skim (v1.5.5) breaks down. Backward search from Skim to Emacs works fine. Any idea? Edit: Even more interesting! I switched symbolic links to x86_64_10_9 versions (rather than x86_64_10_14 versions as Akira originally suggested). Then both forward and backward search work well. Curiously, what are the differences between the different version Dec 18, 2019 at 8:11
  • @MassoChailly The different versions are built for different versions of macOS, so if you're on macOS 10.14 (Mojave) or above then you want to use the _10_14 one. macOS 10.9 to 10.13 then _10_9, and so on. Although, to be honest, I wouldn't expect search to break.
    – Alan Third
    Jan 22, 2020 at 19:58
  • 1
    Hm...this "worked" for me, in the sense that everything behaves as expected using the Catalina "open" command (or the finder). However, now using emacs from inside a terminal window seems broken.
    – acr
    Feb 14, 2020 at 22:35
  • 1
    I also had to use a lower ending number, *_10 in my case, instead of a higher *_14 to get things to work, even when I was on Catalina
    – Paul
    Sep 2, 2020 at 1:10
  • 1
    Thanks! This happily seems to work for me in macOS Monterey 12.2.1, too. Like @lab, I ran into the command-line emacs issue, and resolved it by replacing my emacs symlink with a small shell script that just invokes /Applications/Emacs.app/Contents/MacOS/Emacs -nw "$@"
    – ecmanaut
    Feb 23, 2022 at 23:42
1

There is an error when trying to open another file from Finder when Emacs.app is already running. This erorr is reported in Console:

LaunchedApplication: failed with error -13052 (null){ "ApplicationType"="Foreground", "BundleIdentifierLowerCase"="org.gnu.emacs", "CFBundleExecutablePath"="/Applications/Emacs.app/Contents/MacOS/Emacs", "CFBundleExecutablePathDeviceID"=16777220, "CFBundleExecutablePathINode"=8621172431, "CFBundleIdentifier"="org.gnu.Emacs", "CFBundleName"="Emacs", "CFBundlePackageType"="APPL", "CFBundleSignature"="EMAx", "LSASN"=ASN:0x0-0x49b49b:, "LSBundlePath"="/Applications/Emacs.app", "LSBundlePathDeviceID"=16777220, "LSBundlePathINode"=8621172365, "LSDisplayName"="Emacs", "LSExecutableFormat"="LSExecutable#!Format", "LSLaunchDLabel"="org.gnu.Emacs.5196", "LSLaunchedByLaunchServices"=true, "LSLaunchedWithLaunchD"=true, "LSLaunchEventRecordTime"=154695413870065, "LSLaunchTime"=now-ish 2019/10/24 09:37:28, "LSParentASN"=ASN:0x0-0x2d02d:, "LSWantsToComeForwardAtRegistrationTimeKey"=true, "pid"=50395 }

3
  • Can something more be said about this error? Does this correspond to the case of OP's question (where it's said that there's no error message)?
    – Drew
    Oct 24, 2019 at 2:00
  • Yes, this corresponds to OP's scenario. No error message; nothing happens. But there is an error log shown in Console.
    – Lawrence
    Oct 24, 2019 at 9:35
  • I see the same thing in the Console. Is this a Catalina bug that we expect to be fixed or is it an incompatibility we expect Emacs to fix?
    – HaPsantran
    Nov 25, 2019 at 23:03
0

This ultimately worked for me, as explained in this possibly redundant post I made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.