Open in tmux fails for all files

tmux

I'm having some trouble nailing down a problem I've had with Yosemite for a few weeks now – when I issue the open command inside tmux, all files (PDFs, text files, applications, everything) fail to open with the error code -10810 for all files. Following result:

$ open Coda\ 2.app
LSOpenURLsWithRole() failed with error -10810 for the file /Users/chris/Applications/Coda 2.app.

This happens for all shells (bash, fish, zsh) but only when running under tmux. URLs like open "http://google.com work fine too.

Anyone have any ideas? Here is my PATH:

/Users/chris/.rvm/gems/ruby-2.1.3/bin /Users/chris/.rvm/gems/ruby-2.1.3@global/bin /Users/chris/.rvm/rubies/ruby-2.1.3/bin /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbin /Users/chris/.rvm/gems/ruby-2.1.3/bin /Users/chris/.rvm/gems/ruby-2.1.3@global/bin /Users/chris/.rvm/rubies/ruby-2.1.3/bin /usr/local/opt/coreutils/libexec/gnubin /Users/chris/.rvm/bin /opt/X11/bin /usr/texbin /Users/chris/Applications

Best Answer

There seems to be a usernamespace problem if you want to open OS X apps inside tmux.

To fix that install with Homebrew:

brew install reattach-to-user-namespace

and put this inside your ~/.tmux.conf for the Bash shell:

set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l /bin/bash || /bin/bash"

after that you should be able to open files also in tmux.

Source I got this information: http://uber.pro/here-fishy-fishy/