错误:未在环境中设置XDG_RUNTIME_DIR. Gtk-警告**:无法打开显示: [英] error: XDG_RUNTIME_DIR not set in the environment. Gtk-WARNING **: cannot open display:
问题描述
我曾经以崇高的态度打开文本文件,而对于只读文件,我曾经做过:
sudo sublime
.但是现在突然sudo sublime
命令给出了以下错误:
I used to open text files with sublime, and for Read-only files, I used to do :
sudo sublime
. But now just suddenly the sudo sublime
command gives the following error :
(sublime:3931): Gtk-WARNING **: cannot open display:
而sublime
命令运行正常.我用gedit
尝试了相同的操作,发生了相同的事情,并显示了gedit的错误:
while sublime
command is working fine. I tried the same with gedit
, and the same thing happened, with the error with gedit being shown :
error: XDG_RUNTIME_DIR not set in the environment.
(gedit:3933): Gtk-WARNING **: cannot open display:
我安装了gtk
,并尝试了gksudo
,仍然出现相同的错误!
I installed gtk
, and tried gksudo
, still got the same error!
我在网上搜索后发现了这些方法:
I searched the web and found these ways :
-
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
xhost +localhost
: https://askubuntu.com/questions/614387/gksu-gtk-warning-cannot-open-display-0export DISPLAY=:0.0
:ssh username@hostname -X
ssh username@hostname -Y
- https://superuser.com/questions/310197/how-do-i-fix-a-cannot-open-display-error-when-opening-an-x-program-after-sshi
以上方法均无效.
对我有用的是:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sublime
从此处开始:我想知道为什么我会突然收到这个错误!另外,我想回到sudo sublime
版本,因为它很容易记住.我该如何解决?
I want to know why exactly am I getting this error, that too suddenly! Also, I want to get back to the sudo sublime
version, since it is easy to remember. How can I fix that?
此外,我最近对该系统所做的更改是:
Also, the recent changes I did to the system were :
-
为Ubuntu安装的Mac主题: http://www.noobslab.com/2014/04/macbuntu-1404-pack-is-released.html
已安装gksu(用于gksudo)
Installed gksu(for gksudo)
我们将不胜感激!
推荐答案
我有同样的问题.
在我的情况下,原因是sudo
不继承环境变量:DISPLAY XAUTHORITY
.
The reason in my situation is that sudo
does NOT inherit environment variables: DISPLAY XAUTHORITY
.
对于Ubuntu 14,通过sudo visudo
打开sudoers
文件,然后粘贴:
For Ubuntu 14, open sudoers
file via sudo visudo
, then paste:
Defaults env_keep += "DISPLAY XAUTHORITY"
这篇关于错误:未在环境中设置XDG_RUNTIME_DIR. Gtk-警告**:无法打开显示:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!