Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"xdg_runtime_dir not set in the environment" and pkexec doesn't work

I try to execute the following line on ubuntu-server 14.04:

$ sudo gedit /usr/local/svn/passwd-team

and I get this error:

error: XDG_RUNTIME_DIR not set in the environment.

(gedit: 11805): Gtk-WARNING **: can not open display:

I Googled for help and saw that I had to write:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit

Then I got the following message:

=== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authenticating is needed to run '/usr/bin/env' as the super user
Authenticating as: student,,, (student)
Password:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
=== AUTHENTICATING COMPLETE ===
error: XDG_RUNTIME_DIR not set in the environment.
7
(gedit: 11807): Gtk-WARNING **: can not open display:

Now what? I just want to edit passwd-team file. please guide me. Thanks a lot, Orian.

Edit: I used nano to edit that file, but the error is still there.

like image 340
Orian Zinger Avatar asked Oct 29 '25 15:10

Orian Zinger


2 Answers

I have faced similar issues when using gedit after i ssh into any other user.This may be due to missing permission.

Try the following :-

Open a new terminal from your current user. type in

sudo -i

This prompts for root password. Enter that and then you will be in able to access using root privilege.

Then Try Gedit the file you want to edit. If you need to do it using su for other user then after the above step, do

su <username>

Now Try gedit any file. Works for me.

like image 153
Prateek Mishra Avatar answered Oct 31 '25 10:10

Prateek Mishra


Run the following command:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit /usr/local/svn/passwd-team

Enter your user account password in the password field.

Explanation:

When you run gedit as another user (in this case root) you're in fact starting the new minimal and isolated environment that doesn't carry on some "excessive" variables (among others variables responsible for injecting libraries or setting certain privileges). The command above causes to carry on user-specific X-server settings from the current session.

References:

  1. https://askubuntu.com/a/467994/185132
like image 20
crisron Avatar answered Oct 31 '25 10:10

crisron