LSOpenURLsWithRole() failes with error -10810 on Yosemite from within tmux
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.)
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.
The issue is that tmux is changing the bootstrap to system domain when it shouldn't (see https://trac.macports.org/ticket/18357). Older versions of launchd worked around this bug in tmux, but the rewritten launchd in OS X Yosemite does not work around this tmux bug.
You will either need to wait for Apple to possibly release an update that works around the tmux bug or pester tmux developers to fix this bug in tmux that has been known for at least 6 years now.