Bug 474273

Summary: plasmashell restarted from a non-standard directory may hold open mount points wrongly
Product: [Plasma] plasmashell Reporter: Michael Reilly <OmnipotentEntity>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED NOT A BUG    
Severity: minor CC: kde, nate
Priority: NOR    
Version: 5.27.7   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=474995
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Michael Reilly 2023-09-07 19:41:50 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Mount a USB drive with the GUI widget
2. Shut down plasmashell and relaunch from a command line with a working directory at or below the mount point of the USB drive
3. Attempt to safely remove the USB drive with the GUI widget

OBSERVED RESULT
The USB drive fails to unmount via the GUI widget, or indeed via umount, until the plasmashell is closed and relaunched from a different working directory.  No diagnostic is given.

EXPECTED RESULT
plasmashell should be able to unmount this drive, (by, for instance, changing its current working directory).

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: NixOS 23.05
(available in About System)
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.106.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION
Encountered this issue after a plasmashell crash and I relaunched the plasmashell from the nearest command line handy, which happened to be in a subdirectory of the mounted drive, because I was using it to transfer files.  Because this process was quite time consuming, it wasn't until the next day that I attempted to remove the drive, and I spent a few mystified minutes trying to figure out what was holding the drive open.  I don't think this would be a commonly encountered issue, but it's also one that seems to be easy to fix by changing the current working directory on launch, as plasmashell doesn't seem to be sensitive to this value at all.
Comment 1 Nate Graham 2023-09-08 17:41:12 UTC
How exactly did you quit and relaunch plasma? What command did you use?
Comment 2 Michael Reilly 2023-09-20 16:32:32 UTC
(In reply to Nate Graham from comment #1)
> How exactly did you quit and relaunch plasma? What command did you use?

Sorry about the long delay in response, I seem to have not received a notification. You can reproduce this behavior by doing

$ cd /mount/point
$ kquitapp5 plasmashell && kstart5 plasmashell
$ cd /

to launch the plasmashell from below the mount point, launch plasmashell within the pwd of the mounted drive, then exit the mounted drive (so the shell itself isn't holding the mount point open).
Comment 3 Nate Graham 2023-09-21 15:40:30 UTC
Thanks. Does the problem happen if you restart plasmashell using `systemctl restart --user plasma-plasmashell.service` instead?
Comment 4 Michael Reilly 2023-09-23 17:56:03 UTC
(In reply to Nate Graham from comment #3)
> Thanks. Does the problem happen if you restart plasmashell using `systemctl
> restart --user plasma-plasmashell.service` instead?

The problem does not happen when I use systemctl to restart the service.
Comment 5 Nate Graham 2023-09-25 19:30:35 UTC
Awesome. That's the supported way to restart plasma, so I'd recommend doing that instead of what you were doing before.
Comment 6 Michael Reilly 2023-09-27 17:26:05 UTC
(In reply to Nate Graham from comment #5)
> Awesome. That's the supported way to restart plasma, so I'd recommend doing
> that instead of what you were doing before.

Practically speaking, using `kstart5 plasmashell` is by far and away the most commonly documented process, from both seemingly official (https://userbase.kde.org/Plasma) and unofficial sources.  Particularly the ones that show up when simply performing a web search across a variety of search engines for "kde restart plasma".  In fact, this particular difference seems to have tripped even you up just last year. https://bugs.kde.org/show_bug.cgi?id=448475#c30

I don't mean to be difficult, as I have absolutely no illusions that this is an important bug that needs to be addressed; it's just a obscure, sharp edge that I happened to bump up against.  It just seemed out of left field that a very established and documented pattern is not the supported method.
Comment 7 Nate Graham 2023-09-28 17:51:48 UTC
It has indeed tripped me up in the past. :) One thing I could see us doing is making `plasmashell --replace` run the systemctl command if you're using the systemd boot process.  Let's track that at Bug 474995.