julienXX/terminal-notifier

Hang When Running from Tmux on OS X 10.10 Yosemite

smackesey opened this issue · 28 comments

When I run terminal-notifier from tmux on OS X 10.10 Yosemite, it hangs:

terminal-notifier -message "his name was robert paulson"
# ... hanging

It works fine when running it from outside tmux. This may have something to do with reattach-to-user-namespace. My tmux is configured with this line:

set-option -g default-command "reattach-to-user-namespace -l zsh"

Which was taken from the instructions from this page.

As I said in #106 unfortunately I'm not a tmux user so if someone finds a solution please post it here. My guess is that the issue may lie in reattach-to-user-namespace and yosemite.

cpf commented

In my case, tmux is started through byobu. I'm unsure on what the starting parameters are though. I don't have reattach-to-user-namespace installed, so it shouldn't be that.

Just my two cents, I run Yosemite, tmux, have reattach-to-user-namespace command and it doesn't hang. Did you run bundle update recently?

I'm having the same problem with Yosemite (10.10.0) and tmux (1.9a)
I can confirm that it does work outside of tmux.

I have the same problem, /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -message eggs fails under tmux and works fine in a non-tmux terminal

My install is from Homebrew if that makes any difference.

weirdly enough - it is now working for me inside of tmux. Perhaps it was the update to 1.9a?

It's working for me now too. I updated two things, but I'm not sure which one did the trick:

  • tmux is now 1.9a
  • reattach-to-user-namespace is 2.3

These are both the most recent versions from homebrew. I realized I had an old reattach-to-user-namespace in a scripts dir at the front of $PATH, probably from some old set of instructions from back before there was a reattach-to-user-namespace homebrew formula. So even though my installation was being updated via homebrew, it was always the old one being used. Anyway anyone still having these issues should make sure they have these most recent versions of both tmux and reattach-to-user-namespace.

Anyway anyone still having these issues should make sure they have these most recent versions of both tmux and reattach-to-user-namespace.

Does not work for me. I already had the latest versions:

bessarabov@air:~$ reattach-to-user-namespace --version
reattach-to-user-namespace version 2.3
    Supported OSes: OS X 10.5-10.10
bessarabov@air:~$ tmux -V
tmux 1.9a

I've reinstalled them with brew update; brew reinstall reattach-to-user-namespace; brew reinstall tmux, but it does not help either.

@bessarabov - what version of terminal-notifier are you running? where did you install it from?

@patrickkettner I'm using: 1.6.1 installed via brew:

bessarabov@air:~$ terminal-notifier -version | head -1
terminal-notifier (1.6.1) is a command-line tool to send OS X User Notifications.

I see that in this repo is tag 1.6.2, but brew does not know about it:

bessarabov@air:~$ brew update
...
bessarabov@air:~$ brew install terminal-notifier
Error: terminal-notifier-1.6.1 already installed
To install this version, first `brew unlink terminal-notifier'

@bessarabov try a brew upgrade after brew update.

@bessarabov Thank you, brew upgrade installed terminal-notifier version 1.6.2 (and to be sure I've even restarterd my macbook).

But I still has the problem outside tmux terminal-notifier -message 'asdf' works perfectly well, but in tmux it hangs.

Here are the versions I have:

bessarabov@air:~$ reattach-to-user-namespace --version
reattach-to-user-namespace version 2.3
    Supported OSes: OS X 10.5-10.10
bessarabov@air:~$ tmux -V
tmux 1.9a
bessarabov@air:~$ terminal-notifier | head -1
terminal-notifier (1.6.2) is a command-line tool to send OS X User Notifications.
bessarabov@air:~$

I'm using iTerm, but I checked this behavior in Mac OS default Terminal App. I got the same behaviour in iTerm and in Terminal.app.

I am using tmux and terminal-notifier does and doesn't work for me and I hoped someone could help me understand and fix it. If I execute the following command it works fine.

terminal-notifier -message test

However, when I execute the same command via a tmux new-window shell-command it fails and hangs.

tmux new-window -d -t Background:9999 -n test 'terminal-notifier -message test'

I can confirm that tmux 1.9a (homebrew), reattach-to-user-namespace 2.3 (homebrew), and terminal-notifier 1.6.2 (gem) work on Yosemite 10.10.1.

 ✖ adamyonk
 ➔ tmux -V
tmux 1.9a
 ✖ adamyonk
 ➔ reattach-to-user-namespace --version
reattach-to-user-namespace version 2.3
    Supported OSes: OS X 10.5-10.10
 ✖ adamyonk
 ➔ gem list terminal-notifier

*** LOCAL GEMS ***

terminal-notifier (1.6.2)
terminal-notifier-guard (1.6.4)

I had to remove an older version of reattach-to-user-namespace that I had in my $PATH, so I also had to completely kill/restart the tmux server, then everything worked.

Hi @adamyonk,

Do you have any other configuration set?

I have the same exact setup as you, but my terminal-notifier still hangs inside tmux.

~/ $ tmux -V
tmux 1.9a
~/ $ reattach-to-user-namespace --version
reattach-to-user-namespace version 2.3
    Supported OSes: OS X 10.5-10.10
~/ $ gem list terminal-notifier

*** LOCAL GEMS ***

terminal-notifier (1.6.2)

Also on Yosemite 10.10.1.

Make sure you've killed/restarted tmux so you don't have an old session around. Beyond that, it looks like our setups are the same. I have this as my default-command:

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

Of course @adamyonk!

I had disabled reattach-to-user-namespace. After enabling it back on I can see the notifications just fine.

Thanks 🍻

@buccolo, oh good! So glad it worked!

Can someone explain why reattach-to-user-namespace is required for terminal-notifier when inside tmux?

I use fish shell and tmux. I put set-option -g default-command "reattach-to-user-namespace -l fish in my .tmux.conf and it works now 👍 Thanks @adamyonk

rbf commented

I had the same issue as described here, i.e. terminal-notifier worked only outside tmux since Mac OS X Yosemite. After reading this thread, I can confirm following steps solved the issue for me:

  1. upgrade tmux form 1.9a to 2.0 with brew update && brew upgrade tmux

  2. install reattach-to-user-namespace with brew update && brew install reattach-to-user-namespace

  3. add following lines to at the beginning of my ~/.tmux.conf file (inspired from the commit referenced above):

    # Reattach each new window to the user bootstrap namespace
    # https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
    set -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL -l"

Step 1. alone didn't fix the issue, but adding reattach-to-user-namespace did the trick. As a bonus I can finally use pbcopy and pbpaste inside tmux. 🎉

My current working environment after the upgrades is the following:

sw_vers -productVersion  # Mac OS Version
# 10.10.3
terminal-notifier -v | head -1
# terminal-notifier (1.6.3) is a command-line tool to send OS X User Notifications.
tmux -V
# tmux 2.0
reattach-to-user-namespace -v
# reattach-to-user-namespace version 2.3
#     Supported OSes: OS X 10.5-10.10

That's odd - I have zero problems with pbcopy from within tmux, but the terminal notifier doesn't work

@waynew Yeah, in a recent OS X release, pbcopy/pbpaste etc started to work fine without reattach-to-user-namespace. But I guess whatever Apple/iTerm2 changed doesn't help for this...

These days I don't run gulp on my mac anymore (CPU consumption due to file polling? seriously?), but when I do I just run it outside tmux. easy.

FYI. Followed the steps listed by @rbf in #115 (comment) and now my side terminal-notifier no longer hangs when launched from tmux.

e9t commented

Another similar work-around is to add the line below to .bashrc:

alias terminal-notifier='reattach-to-user-namespace terminal-notifier'

For the record, I've had similar issues before with Sublime Text. Hope that helps in fixing the issue.

Closing the issue, feel free to re-open if there is something I can help with.