linuxmint / mintupgrade

41 stars 16 forks source link

Problem to run mintupgrade #62

Closed vheidari closed 1 year ago

vheidari commented 1 year ago

After install mintupgrade. when I try to run it with this sudo mintupgrade command I get these errors :

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(mintupgrade.py:5045): Gtk-WARNING **: 11:58:42.751: cannot open display: 

There is my release info : /etc/lsb-release

DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=20.3
DISTRIB_CODENAME=una
DISTRIB_DESCRIPTION="Linux Mint 20.3 Una"
vheidari commented 1 year ago

Well, after a bit research I found a solution for my problem. I'm hope this solution help you guys.

The above problem says Sudo couldn't run mintupgrade. It's mean Sudo couldn't connect to X server to run mintupgrade in a graphical mode.

In general Sudo couldn't run a GUI app without $DISPLAY environment variable and .Xauthority file.

To resolve the problem you need to set $DISPLAY variable like this below command. :

export DISPLAY=:0.0
# or
export DISPLAY=:0 

Note: you can use above command either in your terminal or add one of them to your .bashrc in this path ~/.bashrc . also if you are using zsh you can add one of them to this file ~/.zshrc file.

Then try to set Xathority with this below command :

sudo xauth add $(xauth -f ~/.Xauthority list | tail -1)

When both of these requirement are set. Sudo could run GUI app 🔥️🔥️. for example to run mintupgrade you can use this below command :

sudo -E mintupgrade

Don't forget to use -E option. without -E option you should get the error that we talk about that ;)

Good luck guys 🤞️

clefebvre commented 1 year ago

Thanks for this. That said this is a system issue, not a mintupgrade one.

By default your display is set and open to sudoers in Linux Mint, so you should be able to run graphical apps using sudo out of the box. You might have secured your display somehow or used an application which did it for you?

The way we usually open the display is using xhost and setting the display, though you really shouldn't need to have to do this in the first place:

xhost +
export DISPLAY=:0.0

That's typically what you'd type if you wanted to launch a graphical app in your X11 session from a console on tty2 for instance.