mijorus / gearlever

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

[Bazzite] Silent error when changing AppImage default location #89

Open GeeLeonidas opened 2 months ago

GeeLeonidas commented 2 months ago

Recently I've moved to Bazzite (a distro based on Fedora Atomic Desktops) and various things are centralized inside /var, home directory included. When trying to rename Gear Lever's default folder from "AppImages" to "Applications" the interface just didn't react, nothing was changed. After inspecting the output, I've encountered this:

Traceback (most recent call last):
  File "/app/share/gearlever/gearlever/preferences.py", line 124, in on_select_default_location_response
    raise InternalError(_('The folder must be in your home directory'))

Knowing that, I could manage to change the default location to /home/$USER/Applications. The thing is, /var/home/$USER is my home directory and where the file chooser points me to, /home being just a symlink. After analysing the culprit line, it seems to me that GLib.get_home_dir() returns /home/$USER and not /var/home/$USER: https://github.com/mijorus/gearlever/blob/9e6facb5bf38f29d2d686740d7cb96b835cb1e2d/src/preferences.py#L119 Why is that is another thing entirely, but checking for the real path, alongside the current checks, should do the trick.

MMachado05 commented 2 months ago

Potentially unrelated, but how exactly did you access that traceback? Might prove useful in the future!

GeeLeonidas commented 2 months ago

@MMachado05 It was printed to terminal when I ran flatpak run it.mijorus.gearlever, no extra hoops necessary :)

MMachado05 commented 2 months ago

Ah, I'd never considered running it from the terminal! Definitely helpful. 👍

mijorus commented 2 months ago

Hi @GeeLeonidas, that check exists because Gear Lever has write permissions only in the home directory, hence that check. I will try to investigate more, thank you

ao-alt commented 2 months ago

@GeeLeonidas I was able to fix this on Bazzite by editing my /etc/passwd file to change the default home directory of my user from /home/<username> to /var/home/<username>. I'm not sure if that'll cause any problems down the line though.

C-Higgins commented 1 month ago

To clarify the OP, you can fix this by manually typing in the path /home/$USER/Applications instead of picking the folder from the file picker (which will end up as /var/home/$USER/Applications)

selwynorren commented 1 week ago

Hmm only discovered this brilliant app today, but I must admit being able to change the instal path is a little frustrating. I added /opt to my flatseal app for Gear Lever as an access path, but it seems the home location is hard coded and gives this silent error.

Running it through Terminal I get this error: Traceback (most recent call last):

File "/app/share/gearlever/gearlever/preferences.py", line 133, in on_select_default_location_response
    raise InternalError(_('The folder must be in your home directory'))
gearlever.models.Models.InternalError

Can this be changed so that it will use any location of your choosing, just as long as access has been granted to that location using flatseal? or similar app?

I also noticed something else as well, if you click on show welcome screen, there is no way to exit that welcome screen except to run through al the steps. If you try and chnage teh location on the welcome screen, the error is kind of teh same, but slightly different:

Traceback (most recent call last):
  File "/app/share/gearlever/gearlever/WelcomeScreen.py", line 95, in on_select_default_location_response
    raise InternalError(_('The folder must be in your home directory'))
          ^^^^^^^^^^^^^
NameError: name 'InternalError' is not defined
mijorus commented 1 week ago

Hi, the location is hard coded because of the limitations of the Flatpak runtime.

In order to write in /opt, I would have to ask for system wide storage access, which would upset some people.

selwynorren commented 1 week ago

Hmm Makes sense.

I managed to work around it by adding /opt to the path list in Flatseal and then in the code I remove the and statement In preferences.py on line 128

if selected_file.query_exists() and selected_file.get_path().startswith(GLib.get_home_dir()):

becomes

if selected_file.query_exists():

Then I was able to change my installation path to /opt and it worked perfectly. I made the same mod to the welcome.py on line 93

Just curious, would it not be better to rather warn the user that if they select something outside of their home directly they woudl need to add the path to flatseal? Or ever better ask for permission to append the permissions to access the specified folder and restrict it to home and /opt considering that opt is the default location for optional software

I honestly know nothing about this, I was just stabbing in the dark with it and found the solution.

PO.S On another note, should the app not show the welcome screen on first run by default? Again just curious here.

I also have to just say after my small tweak the app worked flawlessly, really nice work done!