Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README example is broken in Ubuntu #16

Closed
MrPowerGamerBR opened this issue Jan 4, 2019 · 9 comments
Closed

README example is broken in Ubuntu #16

MrPowerGamerBR opened this issue Jan 4, 2019 · 9 comments

Comments

@MrPowerGamerBR
Copy link

object Main {
    @JvmStatic
    fun main(args: Array<String>) {
        val client = IPCClient(384465696496549888L)
        client.setListener(object : IPCListener {
            override fun onReady(client: IPCClient?) {
                val builder = RichPresence.Builder()
                builder.setState("West of House")
                    .setDetails("Frustration level: Over 9000")
                    .setStartTimestamp(OffsetDateTime.now())
                    .setLargeImage("canary-large", "Discord Canary")
                    .setSmallImage("ptb-small", "Discord PTB")
                    .setParty("party1234", 1, 6)
                    .setMatchSecret("xyzzy")
                    .setJoinSecret("join")
                    .setSpectateSecret("look")
                client!!.sendRichPresence(builder.build())
            }
        })
        client.connect()
    }
}
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Socket file not found: /run/user/1000/snap.intellij-idea-community/discord-ipc-0
	at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:167)
	at com.jagrosh.discordipc.entities.pipe.Pipe.openPipe(Pipe.java:67)
	at com.jagrosh.discordipc.IPCClient.connect(IPCClient.java:116)
	at com.mrpowergamerbr.powerrp.Main.main(Main.kt:34)
Caused by: java.net.SocketException: Socket file not found: /run/user/1000/snap.intellij-idea-community/discord-ipc-0
	at org.newsclub.net.unix.AFUNIXSocketImpl.validateSocketFile(AFUNIXSocketImpl.java:164)
	at org.newsclub.net.unix.AFUNIXSocketImpl.connect(AFUNIXSocketImpl.java:154)
	at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:138)
	at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:117)
	at com.jagrosh.discordipc.entities.pipe.UnixPipe.<init>(UnixPipe.java:46)
	at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:163)
	... 3 more

I'm running the code directly from IDEA, maybe that's why it isn't working? Discord's IPC socket is in ./run/user/1000/discord-ipc-0 on my system

@MrPowerGamerBR
Copy link
Author

Just for fun I created a symlink ln -s /run/user/1000/discord-ipc-0 /run/user/1000/snap.intellij-idea-community/discord-ipc-0, and...

image

@Shengaero
Copy link
Collaborator

Shengaero commented Jan 4, 2019

If it's not too much to ask, could you add this line to the program near the start and report back what it gives you?

println(System.getProperty("java.io.tmpdir"))

@MrPowerGamerBR
Copy link
Author

@Shengaero /tmp

@MrPowerGamerBR
Copy link
Author

MrPowerGamerBR commented Jan 4, 2019

I decided to add some debug logs to the getPipeLocation to make it easier to debug the issue :3

XDG_RUNTIME_DIR is /run/user/1000/snap.intellij-idea-community
/run/user/1000/snap.intellij-idea-community/discord-ipc-0

I also switched the order of the unixPaths array, and... 🤔

TMPDIR is null
TMP is null
TEMP is null
XDG_RUNTIME_DIR is /run/user/1000/snap.intellij-idea-community
/run/user/1000/snap.intellij-idea-community/discord-ipc-0

Maybe I can set the environment variables, then the issue wouldn't happen, right? Maybe I made a fucky wucky on this Ubuntu installation (first time using Linux on a desktop 😛), but that wouldn't fix the issue since the XDG_RUNTIME_DIR exists, causing the loop to break early.

Also maybe this is happening because I'm running directly from IntelliJ IDEA

@Shengaero
Copy link
Collaborator

It seems like it's an ubuntu related thing.

@MrPowerGamerBR
Copy link
Author

MrPowerGamerBR commented Jan 5, 2019

It actually seems that snap sets the XDG_RUNTIME_DIR automatically for applications installed via snap. (and the tmp & others variables aren't automatically set... my IDEA installation was installed via snap)

Compiling the rich presence and running via the terminal works fine, so it is just an issue if you are running via IDEA itself.

Maybe adding an option to override the socket path when using client.connect()? I think XDG_RUNTIME_DIR is used if you install Discord via snap (in my case: I installed it directly from Discord's website) and you are running the rich presence client via the terminal, but I'm not sure.

@Shengaero
Copy link
Collaborator

you can probably just set that system property from earlier to the new temp dir

@MrPowerGamerBR
Copy link
Author

Installing IDEA via Jetbrains Toolbox fixed the issue.

Maybe adding a small note in the README that, if IDEA is installed via snap/Ubuntu App Store, it won't work/will require workarounds?

@Shengaero
Copy link
Collaborator

This seems very edge case and we won't be putting something in the readme, we will simply refer anyone having trouble to this issue.
Closing this now, thanks for help debugging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants