0

I installed poedit 3.3.1 on my Ubuntu 22.04 and I want to access the .po files found in the var/www/html/ directory. However, every time I try, I get Error opening directory '/var': Permission Denied

I changed the ownership of the var directory and even ran chmod 777 on it but the error persists. I am having to copy the files into the desktop every time, edit them, and then recopy them. Anyone knows how i can run poedit as an admin or fix this issue?

When trying to run sudo poedit I get the following error:

mkdir: cannot create directory '/run/user/0': Permission denied
Authorization required, but no authorization protocol specified
14:21:13: Error: Unable to initialize GTK+, is DISPLAY set properly?

It seems there is some UID issue. When i manually created the directory, the first line of the error disappeared.

Running poedit without sudo opens normally without any errors or warnings.

Update: fixed the sudo issues sudo poedit now works but still have the permission issue.

1 Answers1

1

As a general rule, just do not run graphical programs with sudo at all. If you need to edit something that you don't have permissions for, then it's better to grant yourself the permissions to access the file.

Unfortunately, in this case, it's the Snap system's AppArmor policy limiting the app to accessing only files within your home directory – the file permissions or ownership of /var are most likely not the problem – and although you could edit the AppArmor profile that Snap has installed for poedit, I'm not sure if there's a way to do it persistently. (I'll probably update the post someday, but it might have been already discussed on AskUbuntu.)

One alternative is to run the editor through the sudoedit tool instead – this does not 'sudo' the editor, but instead automates the copying of the file to an accessible location and back:

SUDO_EDITOR=poedit sudoedit /var/html/whatever.po

Alternatively, if the editor is GTK-based, specify an admin:// URL to use GTK's built-in "admin access" feature:

poedit admin:///var/html/whatever.po
grawity
  • 501,077