我曾经以崇高的态度来打开文本文件,而对于只读文件,我曾经做过: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
  • 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

    我想知道为什么我会突然收到这个错误!另外,我想回到sudo sublime版本,因为它很容易记住。我该如何解决?

    另外,我最近对该系统所做的更改是:
  • 为Ubuntu安装的Mac主题: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"
    

    关于ssh - 错误: XDG_RUNTIME_DIR not set in the environment. Gtk警告**:无法打开显示:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33187159/

    10-12 13:00
    查看更多