mijorus / gearlever

Manage AppImages with ease 📦
https://mijorus.it/projects/gearlever
GNU General Public License v3.0
429 stars 15 forks source link

Produce an error log if libfuse is not installed #92

Closed TuxDeluxe closed 2 months ago

TuxDeluxe commented 2 months ago

Currently, if gtk-launch tries to launch the .desktop that points to an app image without fuse installed, the gtk-launch returns 0 which does not trigger an exception even if the app image returns a non-zero code. Though, if ran through gearlever without installing the app image first (skipping gtk-launch and running the app image directly), an error is still not logged through the exception in host_sh.

I leveraged the callback feature provided in host_threaded_sh, run the callback through log_command_output to write an error log to the file but only if fuse is not installed: ERROR [utils.py:160] dlopen(): error loading libfuse.so.2AppImages require FUSE to run. You might still be able to extract the contents of this AppImage if you run it with the --appimage-extract option. See https://github.com/AppImage/AppImageKit/wiki/FUSE for more information

I filtered and only logged the libfuse error because app images could bloat the log file with their own errors not related to the functioning of gearlever itself. Hopefully this change provides some indication for users as to why their app images won't launch.

mijorus commented 2 months ago

Hi, this is a very good suggestion actually, because the missing libfuse situation is a very common issue on some distributions

mijorus commented 2 months ago

I'll keep this PR open while I'm busy with other projects. If you can/want to improve this code, I think it's a good idea which should be develop even further, maybe with the addition of some UI message, like an Adw.Dialog which can guide the user on what to do.

TuxDeluxe commented 2 months ago

I'm not too experienced with windows and window creation and such but I will give it a go. I should be able to bring up a dialog box in the window immediately on launch if the callback detects the libfuse error. The stderr is pretty descriptive on what needs to be done so I'm thinking of displaying that with a few tweaks and inclusions to guide the user to installing fuse.

mijorus commented 2 months ago

If you are now familiar with GTK don't worry. I'll merge this PR as soon as I have a few spare minutes and add all the UI stuff

TuxDeluxe commented 2 months ago

I was able to write an Adw.MessageDialog upon the libfuse error: Screenshot from 2024-06-12 18-05-45 The link provided gives information on how to install fuse on a few distributions so I made it clickable and also included the full stderr in gearlever's log. Feel free to change anything or just scrap it for your implementation when you have time.

mijorus commented 2 months ago

This is perfect, we should probably make the string translatable, but I'll do it later, thank you

TuxDeluxe commented 2 months ago

Also, because appimages also write their own stderr to the callback, it might have to be more specific than just if 'libfuse'. Perhaps the same line you search for in the get_appimage_generation function. I apologise for that oversight.