tmux-plugins / tmux-resurrect

Persists tmux environment across system restarts.
MIT License
11.15k stars 418 forks source link

$DISPLAY is wrong in resurrected session #332

Open zori opened 4 years ago

zori commented 4 years ago

Hi, I've tried both with and without DISPLAY in the update-environment option:

set-option -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"

Either way after rebooting my machine and attaching to a (resurrected) session, the DISPLAY variable is wrong (:0 while it should be :1).

I also use continuum, if that changes anything, with the following settings:

set -g @plugin 'tmux-plugins/tmux-continuum' # Continuous saving of tmux environment. https://github.com/tmux-plugins/tmux-continuum set -g @continuum-save-interval '20' # Save the current session every 20 minutes set -g @continuum-boot 'on' set -g @continuum-restore 'on'

Any known work-arounds?

chrischen commented 4 years ago

Is that env variable updated while your session is running? Because as far as I know this plugin does not persist environment variables (though in my opinion it should).

You can try this plugin but you would have to probably bootstrap the variables back into the environment: https://github.com/tmux-plugins/tmux-resurrect/issues/312.

anindyaspaul commented 4 years ago

I am facing the same issue with DISPLAY variable. The variable is updated using the following statement in .tmux.conf file.

set-option -g update-environment 'DISPLAY'

atifraza commented 4 years ago

I also experienced a similar issue with the DISPLAY environment variable although the variable is not being updated as per my knowledge. The DISPLAY variable is properly set when SSHed into the server. The environment variable is properly set when creating a new tmux session/window/pane. When the session is resurrected, the DISPLAY environment variable is empty in the resurrected windows/panes. Although creating new windows/panes in the resurrected session imports the correct value of the environment variable.

atifraza commented 4 years ago

Update:

Apparently, my problem was possibly related to an outdated version of tmux. I had tmux 1.9 running on a Debian Jessie server. Updating tmux to 2.3 resolved this issue for me.

rcywongaa commented 3 years ago

Issue is still happening. This is causing the resurrected vim's clipboard to not work and also making GUI applications fail

I tried the following to no avail.

run-shell 'DISPLAY=$(cat /proc/$(pgrep -u $USER "^gnome-shell$")/environ | tr "\0" "\n" | grep ^DISPLAY= | cut -d "=" -f 2)'

I believe the problem actually lies in tmux-continuum and not tmux-resurrect. tmux-continuum starts the tmux server before Gnome (or any user GUI). There is no way to know what the correct DISPLAY variable should be. (This is also because tmux is made to work in non-GUI environments as well)

In the end, I just had to remove the line

set -g @continuum-boot 'on'

and the DISPLAY variable was set correctly