JGCarroll / joplin-desktop-snap

MIT License
18 stars 0 forks source link

2.13.12 on Ubuntu 22.04 does not start, permission denied errors in journal #27

Open tyuxar opened 6 months ago

tyuxar commented 6 months ago

I'm using Ubuntu 22.04 latest, snap updated joplin-desktop to 2.13.12. I started it yesterday morning the first time, but the usual window did not appear. Looking into the journal revealed some permission denied messages, e.g.:

Jän 03 07:01:14 t14 joplin-desktop_joplin-desktop.desktop[22782]: chmod: changing permissions of '/home/USERNAME/snap/joplin-desktop/50/.config': Permission denied
Jän 03 07:01:14 t14 kernel: audit: type=1400 audit(1704261674.610:80): apparmor="DENIED" operation="chmod" class="file" profile="snap.joplin-desktop.joplin-desktop" name="/home/USERNAME/snap/joplin-desktop/50/.config/" pid=22782 comm="chmod" requested_mask="w" denied_mask="w" fsuid=1000 ouid=1000
Jän 03 07:01:14 t14 audit[22798]: AVC apparmor="DENIED" operation="open" class="file" profile="snap.joplin-desktop.joplin-desktop" name="/home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs" pid=22798 comm="desktop-launch" requested_mask="wc" denied_mask="wc" fsuid=1000 ouid=1000
Jän 03 07:01:14 t14 joplin-desktop_joplin-desktop.desktop[22798]: /snap/joplin-desktop/50/gnome-platform/command-chain/desktop-launch: line 268: /home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs: Permission denied
Jän 03 07:01:14 t14 audit[22799]: AVC apparmor="DENIED" operation="open" class="file" profile="snap.joplin-desktop.joplin-desktop" name="/home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs.md5sum" pid=22799 comm="desktop-launch" requested_mask="wc" denied_mask="wc" fsuid=1000 ouid=1000
Jän 03 07:01:14 t14 joplin-desktop_joplin-desktop.desktop[22799]: /snap/joplin-desktop/50/gnome-platform/command-chain/desktop-launch: line 269: /home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs.md5sum: Permission denied
Jän 03 07:01:14 t14 kernel: audit: type=1400 audit(1704261674.774:81): apparmor="DENIED" operation="open" class="file" profile="snap.joplin-desktop.joplin-desktop" name="/home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs" pid=22798 comm="desktop-launch" requested_mask="wc" denied_mask="wc" fsuid=1000 ouid=1000
Jän 03 07:01:14 t14 kernel: audit: type=1400 audit(1704261674.774:82): apparmor="DENIED" operation="open" class="file" profile="snap.joplin-desktop.joplin-desktop" name="/home/USERNAME/snap/joplin-desktop/50/.config/user-dirs.dirs.md5sum" pid=22799 comm="desktop-launch" requested_mask="wc" denied_mask="wc" fsuid=1000 ouid=1000
Jän 03 07:01:14 t14 joplin-desktop_joplin-desktop.desktop[22820]: rm: cannot remove '/home/USERNAME/snap/joplin-desktop/50/.local/share/themes': Permission denied

Reverting to 2.13.9 solved the problem, I also set this version to hold.

JGCarroll commented 6 months ago

Hi,

Thanks for the report :)

The errors are coming from a bit of the snap that's shared through a lot of other snaps and isn't unique to Joplin, relating to setting up the desktop integrations.

I'm wondering then what happens if you try install another snap that uses the same components, a good example would be pinta which is a small (~40MB) Paint.NET clone, would you mind trying sudo snap install pinta and then running pinta in the terminal? I'd be curious if it gets similar errors or works successfully.

Apparmor shouldn't really be preventing access here, and there's a chance that there's been a change on your system recently (after installing 2.13.9 but prior to 2.13.12) that means that AppArmor has suddenly started interfering with the integrations. Hopefully knowing if other snaps have started struggling would be helpful with determining what's actually gone on.

tyuxar commented 6 months ago

Thanks James for the quick reply and guide for testing. :) Pinta seemingly worked fine right after the installation, I could start it, did some hand drawing, then exited without saving my masterpiece.

USER@t14:~% sudo snap install pinta
[sudo] password for USER: 
pinta 2.1.1 from James Carroll✪ installed
USER@t14:~% rehash
USER@t14:~% pinta
Gtk-Message: 11:22:49.921: Not loading module "atk-bridge": The functionality is provided by GTK natively. Please try to not load it.
Gtk-Message: 11:22:49.922: Failed to load module "appmenu-gtk-module"

(pinta:220362): GdkPixbuf-CRITICAL **: 11:22:50.564: gdk_pixbuf_calculate_rowstride: assertion 'width > 0' failed

(pinta:220362): GdkPixbuf-CRITICAL **: 11:22:50.564: gdk_pixbuf_calculate_rowstride: assertion 'width > 0' failed
USER@t14:~% 

I'm using zsh, hence the rehash.

Let me know please if I can try something else to help with debugging. (I'm a long time Linux user/administrator, but am not really familiar with Snap.)

Oh, BTW, not to just complain: many thanks for packaging Joplin! :)

JGCarroll commented 6 months ago

Interesting, thanks for trying with Pinta. I'd have to guess since this isn't happening on other snaps on your system, and hasn't been seen elsewhere yet, that it's probably isolated to your Joplin-snap state exclusively, and sounds like just reinstalling it would probably fix the state.

So, option one would be to backup all your notes (Joplin can export to .jex files which are lossless), uninstall the app and reinstall it. Certainly a practical option but not one that helps us understand what's actually happened.

With a more focused approach, the folders that AppArmour is complaining about would be worth inspecting. For the most part, I'd expect them to be symbolic links to the real equivilent folders in $HOME, so for example, /home/USERNAME/snap/joplin-desktop/50/.config should be a symbolic link to /home/USERNAME/.config. If you were to go and inspect that file and it was a dangling symlink, or a file rather than a directory, and etc, it would help understand what's going on.

Although I've no evidence to suggest it is what's gone on, it certainly sounds like the kind of thing that could be caused by moving around $HOME in your partitions and etc.

If you wanted to experiment with fixing it rather than just re-installing to get a clean state, I'd be worth using Snapshots because it would mean you could backup a working copy of the 2.13.9 release, mess around and break it, and roll it back all with snaps own built in tools.

I believe the only folder we actually care about for Joplins own database is $HOME/snap/joplin-desktop/current/.config/joplin-desktop, everything else is local cache that gets regenerated. Hypothetically then, if you were to go into $HOME/snap/joplin-desktop/current/ and delete everything but that folder (importantly including the .last_revision file), it should force everything to be regenerated clean, which should hopefully work given that Pinta does. If it fails, the snapshot should take you back to your current state with your notes intact.

There's also a way to actually run two versions of the same snap called parallel installations, which means you could install the 2.13.12 version alongside 2.13.9 with different folders for each so the two don't interfere.

Ultimately I'll let you decide how much time you'd wish to dedicated to debugging/fixing. Ultimately it sounds like exporting the Joplin data into a .jex, deleting the snap, reinstalling it, and reimporting the .jex would be your easiest solution to just get rolling. Otherwise, you could try using the Snapshots to create backups and mess with the snap folder directly, essentially needing to clear it down to nothingness except for the Joplin config folder above.

Unfortunately it sounds like the kind of thing that will break on any future update until it's resolved, but based on Pinta, not something I'd expect to see twice fortunately.