我曾经用 sublime 打开文本文件,对于只读文件,我曾经这样做:sudo sublime
。但现在突然间sudo sublime
命令给出以下错误:
(sublime:3931): Gtk-WARNING **: cannot open display:
while 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 https://askubuntu.com/questions/614387/gksu-gtk-warning-cannot-open-display-0
-
export 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 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
从这里 :https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut
我想知道为什么我会收到这个错误,太突然了!另外,我想回到sudo sublime
版本,因为它很容易记住。我该如何解决这个问题?
另外,我最近对系统所做的更改是:
为 Ubuntu 安装 Mac 主题:http://www.noobslab.com/2014/04/macbuntu-1404-pack-is-released.html http://www.noobslab.com/2014/04/macbuntu-1404-pack-is-released.html
安装了 gksu(用于 gksudo)
非常感谢您的帮助!
我也有同样的问题。
我的情况的原因是sudo
不继承环境变量:DISPLAY XAUTHORITY
.
怎么修?
对于 Ubuntu 14,打开sudoers
文件通过sudo visudo
,然后粘贴:
Defaults env_keep += "DISPLAY XAUTHORITY"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)