Macos – LSOpenURLsWithRole() failes with error -10810 on Yosemite from within tmux

command linemacosmacportsterminaltmux

Trying to open an application from the commandline (Terminal.app), inside tmux (installed through MacPorts, version 1.9a), and getting the following result:

$ open /Applications/Adobe\ Reader.app/
LSOpenURLsWithRole() failed with error -10810 for the file /Applications/Adobe Reader.app.

The same command works fine, from the same terminal, if executed outside tmux.

Enviroment should be read from host; the following is in tmux.conf : set -g update-environment -r

When restarting terminal.app or tmux, it sometimes errors out with a different message at first, (see below) and when tried again, the above error -10810 is given instead.

$ open /Applications/Adobe\ Reader.app/
The window server could not be contacted.  open must be run with a user logged in at the console, either as that user or as root.

I've tried both Apples own apps (Preview, Font Book, Contacts) and third party (Adobe, Evernote etc). No difference. The one app that does seem to work, is finder. (open [dirname], for instance.)

Best Answer

There is a solution/workaround for this:

  • Update your version of reattach-to-user-namespace. This is used by tmux to execute programs. I use brew rather than macports, so I just did: brew update; brew upgrade reattach-to-user-namespace. Macports is likely to be able to do something similar.
  • Add the following to your .tmux.conf file:

    set -g default-command "reattach-to-user-namespace -l /bin/bash"

Restart your tmux session and that should allow you to start programs from the command line.

Further information can be found at this github issue.

Related Question