discordjs / RPC

A simple RPC client for Discord
MIT License
466 stars 191 forks source link

Fix getIPCPath on darwin (macOS) under a parent process #113

Open SamJakob opened 3 years ago

SamJakob commented 3 years ago

On Darwin (macOS), under a parent process, the environment args might not be correctly passed and os.tmpdir() returns a subdirectory of the root temp dir. This PR therefore uses os.tmpdir() to ensure the environment args aren't modified and gets the parent of the subdirectory if it is detected that the returned temp directory is in a subdirectory.

Benricheson101 commented 3 years ago

Any update on this?

leonardssh commented 3 years ago

@kyranet

kyranet commented 3 years ago

cc: @devsnek

tandpfun commented 2 years ago

This fix doesn't seem to work for me 😦 The paths appear as this which isn't the ipc directory:

CleanShot 2022-07-06 at 11 54 58@2x

My actual IPC directory should be this:

CleanShot 2022-07-06 at 11 56 20@2x
xhayper commented 2 years ago

Here's inline fix

import fs from "fs";

for (const key of ['XDG_RUNTIME_DIR', 'TMPDIR', 'TMP', 'TEMP']) {
    if (process.env[key]) process.env[key] = fs.realpathSync(process.env[key] as string);
}

(i also have a fork that should fix this problem)