discordjs / RPC

A simple RPC client for Discord
MIT License
467 stars 192 forks source link

MacOS IPC Path broken with modified TMPDIR #54

Closed spkane closed 5 years ago

spkane commented 5 years ago

The IPC path on MacOS Mojave is here on my system:

$ find /private/var/folders -name "*discord-ipc*" 2> /dev/null

/private/var/folders/kh/388s01ns6r9480zhlk51nb200000gn/T/discord-ipc-0

I had to modify the ipc.js file to get this working.

I'm assuming that this path is slightly different on people's systems, but a code fix for Darwin system to determine the correct path under /private/var/folders would be very helpful.

I am not using this code directly, but it is a dependency for a plugin I use in my IDE.

Thanks!

devsnek commented 5 years ago

I'm using the same code that discord's reference implementation uses:

https://github.com/discordapp/discord-rpc/blob/4e53fa0392bdb7c301abd48b973204e2cacbaede/src/connection_unix.cpp#L29-L37

https://github.com/discordjs/RPC/blob/1bd83d3b895766e25c457b031079d783678875ff/src/transports/ipc.js#L16-L23

spkane commented 5 years ago

That code simply doesn't work on Darwin/MacOS (at least anymore).

On macOS Mojave that code returns /tmp/discord-ipc-0 on my system.

On MacOS /tmp is a link to /private/tmp, but the IPC file is actually under /private/var and is then still buried further down /private/var/folders/kh/388s01ns6r9480zhlk51nb200000gn/T/discord-ipc-0.

devsnek commented 5 years ago

@spkane it works fine for me and other people i've been talking to about this... are you sure your env isn't messed up?

spkane commented 5 years ago

Not exactly messed up, but I think I see what is happening, now that you posted that image.

In my .bashrc, I very reasonably have set:

export TMPDIR="/tmp"

This impacts Visual Studio Code and the node code, as I want in general, but the issue is that the Discord Desktop does not get that environment, and writes things into the "default" user tmp dir.

Well, I will go ahead and pull that out for now since it is not vital, at the moment.

But, it still feels a bit like a bug somewhere, anyhow.