Emacs GUI will not open over X forwarding from macOS

Tags mac

Symptoms

Emacs will not open when connected to an OSX/macOS computer with "ssh -X" or "ssh -Y."

The following string of errors may appear:

Jul 19 09:02:44  Emacs[87567] <Error>: Set a breakpoint at CGSLogError to catch errors as they are logged.
Jul 19 09:02:44  Emacs[87567] <Error>: This user is not allowed access to the window system right now.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Jul 19 09:02:45  Emacs[87567] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
(error repeated)
2017-07-19 09:02:45.270 Emacs[87567:12773428] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
(error repeated)

Environment

  • macOS
  • Connected to the Mac with ssh -X or ssh -Y

Cause

The Emacs.app program is built to use the macOS window system, not X11.

Resolution

  1. Install emacs with the x11 variant through MacPorts with this command: port install emacs +x11

External Resources

Solution found on Stack Overflow.