Open a-usr opened 4 months ago
This is probably because sudo
resets environment variables, including WAYLAND_DISPLAY
. There is not much Zed itself can do about that AFAIK. Some workarounds do exist though: https://stackoverflow.com/questions/8633461/how-to-keep-environment-variables-when-using-sudo
Perhaps, rather than checking WAYLAND_DISPLAY ourselves, we should let libwayland figure it out and if it errors fallback to X11?
Just as the title describes, if zed is started using sudo or directly from the root user it will try to connect to a XOrg server, even if that server is not running (because wayland is used instead).
Even for the very few GUI programs in my system that let me run them with sudo, they all start with X11 because sudo resets all environment variables. Use the -E
flag with sudo to keep the current environment.
Asides, there's really no good reason to allow a GUI program to run as the super user: Firefox, Dolphin, KWrite, VSCode all prevent me from doing it. It causes many issues (like this one) and is a great security risk. In case we need to edit files with elevated privileges, we can use polkit.
This would be solved by #13585 as it would no longer be necessary to open zed with elevated permissions when it can simply user an authenticated helper service to save system files in the first place.
Check for existing issues
Describe the bug / provide steps to reproduce it
Just as the title describes, if zed is started using sudo or directly from the root user it will try to connect to a XOrg server, even if that server is not running (because wayland is used instead).
Environment
Zed: v1.0.0 (Zed) OS: Linux 1.0.0 Memory: 31.2 GiB Architecture: x86_64
( I am using nixos )
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.No log, but here is the output for when zed is run using sudo or from the root user: