vionya / discord-rich-presence

A cross-platform Discord Rich Presence library written in Rust
MIT License
89 stars 16 forks source link

Couldn't connect to the Discord IPC socket on Ubuntu 22.04 #23

Closed echelon closed 1 year ago

echelon commented 1 year ago

This appears to be the same issue as #2

I'm running this on vanilla Ubuntu 22.04 and am receiving "Couldn't connect to the Discord IPC socket".

Desktop Discord client version:

Stable 152532 (a118a24) Host 0.0.20 Linux 64-Bit (5.15.0-48-Generic)

rustc 1.64.0

discord-rich-presence = "0.2.3"

Linux 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

I'll be happy to provide more details.

Rayrsn commented 1 year ago

Are you running a flatpak or snap version of discord by any chance? because they're known to to be problematic with sockets since they're contained/sandboxed Flatpak Issue. (Solution?) Snap Issue.

echelon commented 1 year ago

Thanks for the info, @Rayrsn !

I've tested running the app as both an Ubuntu Snap and as Discord's provided Debian package, which I assume does not use Flatpak. Both of them are failing to perform IPC.

I can see why the Snap package isn't working, but I'm not sure what's up with the Debian package.

Here's the process running as installed from a deb:

ps -lAf | grep discord

4 S bt        810175    3001  2  80   0 - 9635938 do_pol 15:22 ?      00:00:37 /usr/share/discord/Discord
0 S bt        810179  810175  0  80   0 - 55525 do_pol 15:22 ?        00:00:00 /usr/share/discord/Discord --type=zygote --no-zygote-sandbox
4 S bt        810180  810175  0  80   0 - 55525 do_wai 15:22 ?        00:00:00 /usr/share/discord/Discord --type=zygote
1 S bt        810182  810180  0  80   0 - 55525 do_pol 15:22 ?        00:00:00 /usr/share/discord/Discord --type=zygote
...

Here are the socket files it's attempting to utilize for IPC:

"/run/user/1000/discord-ipc-0"
"/run/user/1000/discord-ipc-1"
"/run/user/1000/discord-ipc-2"
"/run/user/1000/discord-ipc-3"
"/run/user/1000/discord-ipc-4"
"/run/user/1000/discord-ipc-5"
"/run/user/1000/discord-ipc-6"
"/run/user/1000/discord-ipc-7"
"/run/user/1000/discord-ipc-8"
"/run/user/1000/discord-ipc-9"

And that directory shows the socket file as existing,

find /run/user/1000/ | grep discord
/run/user/1000/discord-ipc-0
/run/user/1000/snap.discord
/run/user/1000/snap.discord/.org.chromium.Chromium.ZzV6Er
/run/user/1000/snap.discord/.org.chromium.Chromium.ZzV6Er/discord1_2.png
/run/user/1000/snap.discord/discord-ipc-0
/run/user/1000/snap.discord/.org.chromium.Chromium.kowpPo
/run/user/1000/snap.discord/.org.chromium.Chromium.kowpPo/SS
...

But it's a broken symlink!

ls -lA /run/user/1000/discord-ipc-0
lrwxrwxrwx 1 bt bt 55 Oct 18 15:47 /run/user/1000/discord-ipc-0 -> /run/user/1000/app/com.discordapp.Discord/discord-ipc-0

ls -lA /run/user/1000/app/com.discordapp.Discord/discord-ipc-0
ls: cannot access '/run/user/1000/app/com.discordapp.Discord/discord-ipc-0': No such file or directory

Not sure what happened here or what app caused this state.

I deleted it, restarted, and everything works!

Edit: Not sure where the broken symlink came from, or if this is your library's responsibility or opportunity to ameliorate.

vionya commented 1 year ago

I deleted it, restarted, and everything works!

To clarify, is this referring to deleting the broken symlink and then restarting Discord?

In any case, I can tell you that the library does not create symlinks at any point, it only looks for open pipes under the given paths. It is possible that the broken symlink was created by a Flatpak installation of Discord, and wasn't overwritten by the Debian package.

Sorry for the late response!

echelon commented 1 year ago

To clarify, is this referring to deleting the broken symlink and then restarting Discord?

Correct

It is possible that the broken symlink was created by a Flatpak installation of Discord

It was probably the Snap version of Discord that did this. I used a fresh Ubuntu system and confirmed that I only installed and ran Ubuntu's Snap and Discord's own .deb.

This is a Snap problem and there's nothing for you to do. I'll close the issue.

Thanks for the help!