Closed j0of closed 2 days ago
Hi j0of,
Unfortunately I don't have much experience with WSL, so I do not have any specific solution for this as of now. Looking at the error message, the library detected that it was run in a Unix environment and tried to search for a socket (it checks the env variables XDG_RUNTIME_DIR
, TMPDIR
, TMP
, and TEMP
for a path, then attempts to connect to a socket from 0 to 9), but it could not find one that it could connect to.
Depending on your use case, it might just be better to move Discord or your Python script so that it is in the same environment, but if you don't want to do that, here are my quick thoughts:
sys.platform = "win32"
so that the library looks for a Windows socket instead. Not sure if this would work but it's worth a try.Let me know if this helps.
Random passer-by who happen to hit the same issue. The library works exactly as expected outside of WSL2. The issue with WSL2 is due to a lack of AF_UNIX socket interop. This seems to impact WSL2 and "WLS" (the now default install) but not WSL1.
A dev can work around this with some socat and npiperelay.exe hops but I opt'ed to just run out of Windows.
Hi, I'm working on a Windows 11 device, but I like to keep everything related to development/programming on my Linux Subsystem (Ubuntu) and everything else on the C:/ drive. So, I have Discord on my C:/ drive and the .py file on WSL. This causes me to get the following error: Traceback (most recent call last): File "/home//.local/bin/rpc.py", line 6, in
with Presence(client_id) as presence:
File "/home/joof/.local/lib/python3.10/site-packages/discordrp/presence.py", line 68, in init
_WindowsSocket() if sys.platform == "win32" else _UnixSocket()
File "/home//.local/lib/python3.10/site-packages/discordrp/presence.py", line 202, in init
raise FileNotFoundError("Cannot find a Unix socket to connect to Discord")
FileNotFoundError: Cannot find a Unix socket to connect to Discord
I'm pretty sure I could just fix this by moving the .py file to Discord, but for the sake of not having to install Python twice on my laptop, is there any way I can get this to work? If not, I wouldn't mind if I had to install Python again, it would just be slightly less convenient 🙃
Thanks!