If I'm running within tmux and I try to update an environment variable with launchctl, I see an error like this:

$ launchctl setenv GIT_SSH /opt/local/bin/ssh
Not privileged to set domain environment.

But it works fine from outside of tmux... any idea why that is, or if there's any sort of workaround?

  • 1
    How did you launch tmux? If from command line, launch tmux with sudo. If it is an app, sudo open /path/to/tmux.app – TheBro21 Apr 22 '15 at 7:34
  • 1
    Try running tmux with sudo(sudo tmux) to give it admin privileges – TheBro21 Apr 22 '15 at 11:21

Running tmux as root is probably not a good idea. Someone has created a solution and explanation:


After configuring tmux to use reattach-to-user-namespace you can use launchctl setenv as yourself within tmux.

  • FWIW, I found that several years ago, and just didn't remember to answer my own question... But, yes, the tmux-pasteboard package from MacPorts does the trick. – pioto Apr 20 '17 at 14:06

You need to run it from a privileged account i.e.

$ sudo launchctl setenv GIT_SSH /opt/local/bin/ssh

And enter your password when prompted. This can only be done from an admin account by default.

  • It works fine w/o sudo, when I run it outside of tmux... I'll see if sudo is somehow necessary from within tmux, but that doesn't really seem like the sort of thing I'd want to include in my ~/.bashrc... – pioto Apr 22 '15 at 5:10
  • 1
    Yes, running through sudo seems to work, but I still don't like it... For now, I'm just going to wrap the calls to this in my ~/.bashrc in if [[ -z "$TMUX"]] ; then ... – pioto Apr 22 '15 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .