tmux-MacOSX-pasteboard icon indicating copy to clipboard operation
tmux-MacOSX-pasteboard copied to clipboard

Opening URLs with `open` under Yosemite fails

Open mrnugget opened this issue 10 years ago • 5 comments

I've been using tmux and reattach-to-user-namespace for a long time now (thanks a lot for your work!) and the combination worked flawlessly, until my upgrade to Yosemite. Now I get this error, when trying to open a URL (this is inside a tmux session):

% reattach-to-user-namespace -v
reattach-to-user-namespace version 2.3
    Supported OSes: OS X 10.5-10.10
% open http://www.google.com
LSOpenURLsWithRole() failed with error -600 for the URL http://www.google.com.
% echo 'foobar' | pbcopy
% foobar

My tmux configuration contains this line:

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

And that works with pbcopy and pbpaste, but fails with open.

The open commands also works outside of tmux.

Now, I'm not too sure if this project is the right place for this issue, but it seems like that every other issue recommends looking at reattach-to-usre-namespace.

I already had that installed and in use for a long time, I'm on the latest version too, so I thought I'd open this issue to see if we can get to the bottom of this.

If you need any more information, please tell me!

mrnugget avatar Dec 15 '14 06:12 mrnugget

Unfortunately, I do not currently have any solid advice for this problem.

I have encountered this situation in the past (on Mavericks, at least), but I have never been able to recreate it on demand. For example, at this moment, your example (open http://www.google.com) works fine on my Yosemite system. There is probably some particular sequence of actions will put the system into this open-URL-fails-but-pasteboard-access-is-okay state, but I have not been able to narrow it down.

I feel like this problem probably is related to the bootstrap namespace issue that the wrapper program addresses, though it is obviously not identical. I certainly do not mind having an open issue about it. It might help collect useful information even if the ultimate solution does not fit well with the existing wrapper program.

Does open-URL work if you try it under a new server? With your default-command configuration in place, from outside tmux (in a plain Terminal/iTerm window) run

tmux -L fresh new 'open http://google.com;echo exited $!;read'

(press Enter or C-d, or C-c to finish the read command; fresh can be any identifier that does not refer to a currently running tmux server)

If that works, then restarting your server (i.e. exiting your existing sessions and starting new ones in a fresh server process) might serve as a workaround of sorts. This may not be feasible if you have sessions that are hard to conveniently recreate. But if it does work, it might help you narrow down what event(s) might reproduce this problem.

Do you use a particularly long-lived tmux server process (e.g. leave a session open while logging out of you GUI session)? My impression is that this problem might be related to how GUI sessions relate to tmux server process lifetimes, but I have not been able to prove it.

ChrisJohnsen avatar Dec 15 '14 09:12 ChrisJohnsen

tmux -L fresh new 'open http://google.com;echo exited $!;read'

This works!

Restarting the tmux server works too. That's what I did in the past few months since Yosemite to work around this issue. But I have a lot of long lived sessions (effectively workspaces for different projects).

Maybe this is relevant: after upgrading to Yosemite my OS X ssh-agent stopped working after a day or so in long-lived tmux sessions. This worked perfectly fine before, but after the upgrade, tmux couldn't handle a change in $SSH_AUTH_SOCK anymore. I had to add this line to my tmux.conf to make it work again.

As I said, this might not be relevant, but both issues (ssh-agent and open) only appeared for me with long-running sessions. Both weren't a problem before, only after Yosemite.

I also sometimes logout of my GUI session (computer goes to sleep, locking the screen) and then come back.

Is there any way I could give you more debug information? any ideas as to what to look out for?

My guess is that something outside the tmux session/server changes and tmux doesn't update its environment accordingly. At least that was the problem with ssh-agent. (Just tried updating Apple_PubSub_Socket_Render and DISPLAY inside the tmux session, but open still doesn't work. My guess was that both are managed by launchd too)

mrnugget avatar Dec 15 '14 13:12 mrnugget

I just thought I'd update the status of this issue here: it all works. I'm currently on 10.10.4, using tmux 2.0 and reattach-to-user-namespace 2.4. Maybe one of the Yosemite upgrades fixed this along the way.

mrnugget avatar Jul 02 '15 09:07 mrnugget

FWIW, I'm on 10.10.4, using Tmux 2.0, and reattach-to-user-namespace 2.4, and I periodically run into the same issue; restarting the Tmux server fixes the issue.

finbarrtimbers avatar Sep 02 '15 22:09 finbarrtimbers

I'm running into this exact issue using tmux 2.0, OSX 10.11.6, and reattach-to-user-namespace 2.5. Specifically:

  • open ANY_URL fails with LSOpenURLsWithRole() failed with error -600 for the URL http://google.com.
  • ssh-agent stops working
  • If I quit all tmux sessions, open URL works again

Here's my tmux.conf.

gabebw avatar Sep 29 '16 03:09 gabebw