Full error message for sudo /usr/local/bin/tlmgr -gui (TeX Live 2017 manager) I'm getting on my OpenSUSE Tumbleweed with Gnome 3:
No protocol specified
perl/Tk unusable, cannot create main windows.
That could be a consequence of not having X Windows installed or started!
Error message from creating MainWindow:
couldn't connect to display ":0" at /usr/lib/perl5/vendor_perl/5.24.1/x86_64-linux-thread-multi/Tk/MainWindow.pm line 53.
Tk::MainWindow->new() at /usr/local/bin/tlmgr line 4704.
No such error message when starting it without sudo (can't use it this way though since I installed it system-wide).
Same result if
- doing
sudo -H - doing it inside
sudo -i(should be the same assudo -HAFAIK) - using
pkexecinstead ofsudo(apparently the new replacement forgksu/gksudo?)
Then I tried being clever and played around with the X authority file (got the idea from posts such as https://unix.stackexchange.com/a/8250):
ln -s /run/user/1000/gdm/Xauthority /root/.Xauthority
# inside sudo -i then
export XAUTHORITY=/root/.Xauthority
After that I'm getting the error message with the following first two lines (and the rest the same as previously):
Invalid MIT-MAGIC-COOKIE-1 keyperl/Tk unusable, cannot create main windows.
That could be a consequence of not having X Windows installed or started!
Output for xauth list:
linux-q1xc/unix: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
#ffff#6c696e75782d71317863#: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
For sudo xauth list:
linux-q1xc/unix:10 MIT-MAGIC-COOKIE-1 7e608058d97a6bf4ae346879f4f5fd46
For ssh -X localhost xauth list:
linux-q1xc/unix:10 MIT-MAGIC-COOKIE-1 faaf2ba1724d5efe85aa5ef6cb4fcc52
For ssh -X root@localhost xauth list:
linux-q1xc/unix:10 MIT-MAGIC-COOKIE-1 e8168ff05f56458663f187ec38f744fe
After sudo ln -sf ~/.Xauthority /root
Output for xauth list:
linux-q1xc/unix: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
#ffff#6c696e75782d71317863#: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
Output for sudo xauth list:
linux-q1xc/unix:10 MIT-MAGIC-COOKIE-1 faaf2ba1724d5efe85aa5ef6cb4fcc52
Error message is again the first one.
xauth list output inside su - or using sudo -E (both where it works):
linux-q1xc/unix: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
#ffff#6c696e75782d71317863#: MIT-MAGIC-COOKIE-1 fa445a3c038b19300e8e45d4ae0ae55a
(Same as the first one.)
Works with ssh -X localhost tlmgr -gui. Also works inside su - and using sudo -E.
What is the underlying issue and how can it be solved?
xauth list? – Satō Katsura Jun 06 '17 at 13:41ln -sf /home/your_user/.Xauthority /root/. After thatxauth listandsudo xauth listshould have the same output. – Satō Katsura Jun 06 '17 at 13:59su -, which as opposed tosudo -ihas e.g.XAUTHLOCALHOSTNAMEandDISPLAYset. AlsoXAUTHORITYis set to/root/.auth<RANDOM>. – phk Jun 06 '17 at 14:37DISPLAY(or a -display option, if the command accepts it) would be a showstopper. The answer to this question https://unix.stackexchange.com/questions/203136/how-do-i-run-gui-applications-as-root-by-using-pkexec tells how to get pkexec to retain yourDISPLAYvariable. – Mark Plotnick Jun 06 '17 at 19:39