I get this error when I try to launch Sublime Text or SourceTree from tmux:

$ subl
Unable to launch Sublime Text 2

$ stree
Unable to open SourceTree

It seems that I can't open os x apps either:

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

I'm using Yosemite OS X 10.10 (14A388a), iTerm 2 with zsh, tmux 1.0a. Had the same problem using bash. Any idea what's going on?

  • Not just a tmux problem for me. Same in bash and zsh/oh-my-zsh. It worked – J. B. Rainsberger Nov 2 '14 at 14:06

Update: This is procedure is unnecessary with tmux >= v2.6

I found a post by Brendon Rapp describing a solution that doesn't require lots of aliases.

$ brew install reattach-to-user-namespace

Add the following line to the end of your ~/.tmux.conf:

if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'

Create a file named ~/.tmux-osx.conf with the following contents:

set-option -g default-command "reattach-to-user-namespace -l bash"
  • The above solution allows the same .tmux.conf file to work correctly under both Linux and OS X. If you only use OS X, you can just add the 'default-command' option directly to your ~/.tmux.conf.

  • If you use a shell other than bash, replace 'bash' with your shell after the '-l' switch.


I had the same problem with tmux and patched it with reattatch-to-user-namespace and shell aliases.

  1. $ brew install reattach-to-user-namespace
  2. $ vi ~/.bash_aliases

    alias subl='reattach-to-user-namespace subl'
    alias stree='reattach-to-user-namespace stree'
    alias open='reattach-to-user-namespace open'
  3. $ source ~/.bash_aliases

Not elegant, but works.

  • 2
    According to the docs, just add this to your ~/.tmux.conf: set-option -g default-command "reattach-to-user-namespace -l zsh" – nicerobot Apr 4 '15 at 22:47

I found that adding this to my aliases didn't work for me if I wasn't already in a tmux session (i.e. it threw an error if I was just in a naked, tmux-less iTerm session).

If you want to only set up this alias when you're in a tmux session, try this instead:

if [ "$TERM" = "screen" ] && [ -n "$TMUX" ]; then
  alias stree="reattach-to-user-namespace stree"

You may need to echo $TERM inside of a tmux session to see what your $TERM environment variable is set to. Mine was actually screen-256color, so I swapped out the value above appropriately.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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