Adamcake / Bolt

An alternative launcher for your favourite MMO
GNU Affero General Public License v3.0
162 stars 23 forks source link

Trouble with shimmed java, and a lack of feedback #24

Closed agwhitaker93 closed 7 months ago

agwhitaker93 commented 7 months ago

I have to use different versions of java for work, so I use asdf-vm to help switch versions. I also use fish as my login shell, which might be complicating things.

If I don't have JAVA_HOME set, Runelite silently fails to launch, and I see unknown command: java. Perhaps you have to reshim? Screenshot_20240221_010846

Which suggests Bolt is picking up the shimmed java that asdf provides from my PATH, but can't use it because it's not being initialized in the forked process Bolt starts. I don't have any experience with systems level development, but I'm guessing that's expected behaviour.

I didn't have JAVA_HOME set when I first installed Bolt, and it took me an embarrassingly long amount of time to figure out doing so would fix things. Similarly, having JAVA_HOME set to something invalid makes Bolt silently error.

All that to say, it would be nice if Bolt gave me some insight into why it's not launching Runelite, or even tell me it's failing to launch in the first place.

I'm happy to have a go at adding some error messages to the UI, if that's okay with you, but the last time I touched C++ was over a decade ago in university so it may take me a while

Adamcake commented 7 months ago

If JAVA_HOME is set RuneLite will always launch based on that, but if it's not then it should try running java from your path instead. As you said it seems it's finding something in the path and then asdf is reporting an error.

From a quick search it looks quite likely that asdf is trying to find something relative to your home directory, or possibly the defaults of some XDG dirs relative to your home directory. We overwrite HOME for the runelite process because it seems to be the only way to get it to change the location of its .runelite folder. So that could be the problem. Look into setting ASDF_DIR and ASDF_DATA_DIR.

In terms of errors we don't have much to go on apart from what's returned from fork and exec. As long as the OS is happy to start a process and that process starts up correctly (even if that process is just an asdf shim) then it looks like a success from our point of view.

agwhitaker93 commented 7 months ago

Ahh, that makes sense. Sorry, I should have thought to check that myself. Setting ASDF_DATA_DIR works.

Bolt should be getting an exit code of 1 when it fails to use the asdf shim Screenshot_20240221_153341

If JAVA_HOME is invalid, it looks like Bolt still tries to use java_home_str and gets into a weird state that causes it to hang Screenshot_20240221_161230

If Bolt logs Successfully spawned game process, does that mean the process started up correctly, at least as far as Bolt's concerned? It looks like that's happening in both cases

Adamcake commented 7 months ago

Bolt should be getting an exit code of 1 when it fails to use the asdf shim

It only checks that the process started correctly, it doesn't wait around for an exit code. Considering it's launching a game client, it might not get an exit code for any number of hours.

If JAVA_HOME is invalid, it looks like Bolt still tries to use java_home_str and gets into a weird state that causes it to hang

Not very surprising, I wouldn't expect anything Java-related to work if JAVA_HOME is configured incorrectly.

If Bolt logs Successfully spawned game process, does that mean the process started up correctly, at least as far as Bolt's concerned?

Yes, it just means that fork() didn't return an error. Beyond that point, it's a separate process.

Adamcake commented 7 months ago

"Successfully spawned with PID 0" doesn't look correct though.

agwhitaker93 commented 7 months ago

Not very surprising, I wouldn't expect anything Java-related to work if JAVA_HOME is configured incorrectly.

Yeah, I agree, I don't expect it to work either. It might be worth checking that it points to a usable java before trying to use it though, instead of silently failing like it does now

agwhitaker93 commented 7 months ago

If you think it's worth surfacing errors around JAVA_HOME not being set correctly, I've opened a PR: https://github.com/Adamcake/Bolt/pull/25

Adamcake commented 7 months ago

Thanks- I'll also try to recreate that "success with PID 0" thing when I get a chance but I'd say it's separate from this issue.

agwhitaker93 commented 7 months ago

Aye aye. I'll do some digging on my end too