我曾经以崇高的态度来打开文本文件,而对于只读文件,我曾经做过:sudo sublime
。但是现在sudo sublime
命令突然出现以下错误:
(sublime:3931): Gtk-WARNING **: cannot open display:
而
sublime
命令运行正常。我用gedit
尝试了相同的操作,发生了相同的事情,并显示了gedit的错误:error: XDG_RUNTIME_DIR not set in the environment.
(gedit:3933): Gtk-WARNING **: cannot open display:
我安装了
gtk
,并尝试了gksudo
,仍然遇到相同的错误!我在网上搜索并找到了以下方法:
xhost +localhost
:https://askubuntu.com/questions/614387/gksu-gtk-warning-cannot-open-display-0 export DISPLAY=:0.0
:ssh username@hostname -X
ssh username@hostname -Y
以上都不起作用。
对我有用的是:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sublime
从这里:https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut
我想知道为什么我会突然收到这个错误!另外,我想回到
sudo sublime
版本,因为它很容易记住。我该如何解决?另外,我最近对该系统所做的更改是:
帮助将不胜感激!
最佳答案
我也有同样的问题。
在我的情况下,原因是sudo
不继承环境变量:DISPLAY XAUTHORITY
。
怎么修?
对于Ubuntu 14,通过sudoers
打开sudo visudo
文件,然后粘贴:
Defaults env_keep += "DISPLAY XAUTHORITY"
关于ssh - 错误: XDG_RUNTIME_DIR not set in the environment. Gtk警告**:无法打开显示:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33187159/