Bug 370975 - device notifier pretends it cannot mount usb device while actually mounting it
Summary: device notifier pretends it cannot mount usb device while actually mounting it
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Disks & Devices (show other bugs)
Version: 5.12.2
Platform: Kubuntu Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: usability
: 391381 391386 391717 395065 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-10-16 22:26 UTC by Éric Brunet
Modified: 2020-03-23 18:46 UTC (History)
34 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.46
Sentry Crash Report:


Attachments
device notifier workaround (1.15 KB, patch)
2018-05-01 15:42 UTC, Mariusz Libera
Details
Requested dbus-monitor.log (1.02 MB, text/x-log)
2018-05-01 18:52 UTC, Xwang
Details
dbus-monitor log on Arch Linux, plasma 5.12.5 (1.08 MB, text/plain)
2018-05-01 19:46 UTC, Patrick Silva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Éric Brunet 2016-10-16 22:26:44 UTC
I plug a USB key. Device notifier pops up, and I click "open in file manager"

Instead of dolphin appearing, I have an error box titled "Error KIO Client" with the text
"malformed URL" and an "Ok" button. This error box seems to be from kde-open5 launched with a single argument which is an empty string, as in:  kde-open5 ''

Dolphin did not appear, but my usb key is now mounted: I can even see the bar in the device notifier telling me how full it is.

If I click again on "Open in file Manager" in the device notifier, I no longer have the "malformed url" error, but I have instead  two error messages:
1) one inside the device notifier popup: "You are not authorized to mount this device"
2) one in a new Plasma popup: "Devices notifications".  "Could not mount the following device:...." 

I can click as many times as I want "Open in file manager", I have always the same answer.

Again, the device is mounted from the first click in the device notifier. I can launch dolphin manually and browse it with no difficulty. The device-notifier knows it is mounted, because it displays the small bar. And I can unmount with no difficulty the usb key from the device notifier itself by clicking the small underlined triangle on the right. But device notifier makes an error instead of running dolphin.

When this bug starts to happen it never disappears without a reboot.

After a fresh boot, the bug is sometimes there from the start, and sometimes it is not: the device-notifier works perfectly! But at some point (I don't know what causes the problem) the bug appears again.

I see this on two computers, with several different usb devices (keys and hard drives).

Reproducible: Sometimes
Comment 1 Marco Martin 2016-10-18 10:52:11 UTC
do the two computers use the same distribution/plasma version/distribution version?
Comment 2 slartibart70 2016-10-18 19:59:54 UTC
Same here, fedora 23, plasma 5.7.5
Happens most of the time when plugging in a usb3 stick into a usb2.0 port on a lenovo t420 laptop - this was working properly before the latest updates.

As mentioned above, the error message appears but the stick is mounted properly.
No such error messages when moutning/umounting on commandline without kde device notifier.
Comment 3 Éric Brunet 2016-10-18 20:35:10 UTC
(In reply to Marco Martin from comment #1)
> do the two computers use the same distribution/plasma version/distribution
> version?

Both computers are fedora 23. One is up to date (plasma 5.7.5), the other not quite (plasma 5.7.3).

But I have been experiencing this bug for a long time: it has been present for several version of fedora and of plasma. Unfortunately, I cannot say since when. Several times, I have simply waited for the next update, and was in the impression that the next update did fix it.  (And maybe it has been fixed for some period of time?) But at some point the bug would reappear. As it doesn't occur every time, and as I don't use so often an external drive, it is hard for me to be precise.
Comment 4 brancaleone 2016-11-10 07:36:23 UTC
I'd like to confirm the same issue on openSuse 42.1, plasma 5.8.3 and qt 5.6.2.

The bug is always reproducible. I also noticed that sometimes after a reboot it works for a while, but not everytime (and i don't reboot the laptop often).

I've also had this issue for a while.
Comment 5 Tim Middleton 2016-11-27 11:32:53 UTC
Same issue on Arch with plasma 5.8.4, Qt 5.7, KDE Frameworks 5.28.0
Comment 6 chx1975 2016-12-02 23:56:13 UTC
Confirmed. I can reliably reproduce this, Arch Linux here as well and ready to help with debugging.
Comment 7 brancaleone 2017-01-20 08:29:57 UTC
I can confirm this bug is still present in 5.8.95.

It get sometimes fixed after a reboot but not always. Today the problem appeared again after a resume from suspend. I'm not sure of what triggers the bug, but when it's present i have no way to make it go away.

I can provide more technical information if you let me know where to look for thems.
Comment 8 Mahendra Tallur 2017-01-25 23:04:09 UTC
Hi ! Same issue under KDE Neon LTS, KDE Plasma 5.8.5, Framework 5.30.0.
Comment 9 Alexander Mentyu 2017-12-09 14:34:15 UTC
Can't reproduce in:

Distribution: KDE neon Developer Edition - Stable Branches
Plasma: 5.11.4
Frameworks: 5.41.0
Qt: 5.9.3
Kernel 4.10.0-40-generic

Tried multiple times on different flash drives
Comment 10 brancaleone 2018-01-31 13:21:47 UTC
It still happens in OpenSuse 42.2 :

Plasma : 5.11.95
Framework : 5.42.0
QT : 5.10.0
Kernel : 4.4.104

Note that after install, an upgrade or sometimes after a reboot it works. But after some times it breaks and stays broken until next upgrade.

Note also that in my case this is a laptop and goes often on standby.
Comment 11 ed.shornock 2018-02-16 19:50:12 UTC
I'm able to reproduce this on two different systems in Debian unstable with plasma 5.12.0.
Comment 12 ed.shornock 2018-02-16 19:59:38 UTC
(In reply to ed.shornock from comment #11)
> I'm able to reproduce this on two different systems in Debian unstable with
> plasma 5.12.0.

Additional info:

If I try to mount the device in Dolphin I see a red error, stating
"An error occurred while accessing 'Home', the system responded: The device is already mounted: Device /dev/sdl1 is already mounted at '/media/myuser/disk title'.

The Device Notifier shows "You are not authorized to mount this device." but the device **is** mounted. It also shows the bar graph depicting the space used.

The journal shows " systemd[1]: Started Clean the /media/myuser/disk title mount point"
Comment 13 luca 2018-02-19 12:58:27 UTC
confirmed in debian buster

plasma 5.10.5
kde framework 5.37.0
Qt 5.9.2
Comment 14 Patrick Silva 2018-02-21 22:50:40 UTC
plasma 5.12.2 is affected on Arch Linux.
Comment 15 luca 2018-02-24 17:12:29 UTC
this error is a bit annoying
I tried to automount the devices on attach (with systemsettings removable device module) and a bit helps
Comment 16 Patrick Silva 2018-02-24 17:29:36 UTC
(In reply to Dr. Chapatin from comment #14)
> plasma 5.12.2 is affected on Arch Linux.

I can reproduce this bug when automount is disabled in "removable devices" kcm and two removable devices are available (CD/DVD/BD and pendrive, for example).
Comment 17 Patrick Silva 2018-03-04 20:56:44 UTC
*** Bug 391381 has been marked as a duplicate of this bug. ***
Comment 18 dolgener 2018-03-06 13:03:43 UTC
I can confirm this behavior on debian testing, with KDE Frameworks 5.42.0, too. 

However: the fact that its probability of occurrence increased drastically after I switched to a more powerful workstation, suggests that this "Malformed URL" errors are some kind of timeout phenomenon. In other words, plasma seems to give up too early on a faster machine, when the ponderous USB device isn't quite ready yet.

It might be helpful if plasma could wait some additional ~250 ms before throwing this error?
Comment 19 d_tassos 2018-03-08 06:55:50 UTC
Can confirm. (Manjaro, Plasma 5.12.2)

Since last update this happens now on both my systems every time.

When inserting a USB stick and choose the "open in file manager" in the device notifier I get the malfomed URL error, but the USB stick mounts anyway. If you choose it again it will open in dolphin as intended.

There is no problem if you mount by clicking on it on the devices sidebar in dolphin.
Comment 20 Patrick Silva 2018-03-11 19:27:46 UTC
*** Bug 391717 has been marked as a duplicate of this bug. ***
Comment 21 humufr 2018-03-12 10:41:56 UTC
Still present in 5.12.3 on Archlinux.

When using the device notifier and trying to mount and open the device with the option "Open with File manager". I am getting, if unmounted, an error message with the "Malformed URL".
Comment 22 Attila 2018-03-12 12:24:17 UTC
This bug is new to Fedora 27. Everything was fine before the latest update (couple of weeks ago).

This bug is alwas reproducible on Fedora.

Additional info:
Even when I am using Dolphin and try to mount a partition on my harddrive which is not mounted, I get an error message inside of Dolphin.
Please check my bug report (Bug 391717) which is marked as duplicate, because I believe that the symptoms of this bug here were different then my in the beginning (they are not excatly the same).
Comment 23 Mariusz Libera 2018-03-21 13:59:11 UTC
Same here, Archlinux.
Plasma 5.12.3
frameworks 5.44.0
applications 17.12.3

Very annoying bug.
Comment 24 Gerry Gavigan 2018-03-24 11:26:27 UTC
my experience in opensuse is that if subsequently I unmount the usb stick on the command line the "malformed URL" problem goes away - weird that it is cross-distro as otherwise I would suggest it is not a KDE problem. 

Not sure if is it related, but simultaneously with until recently I could hot plug a USB caddy containing a NTFS 1Tb hard drive (for lazy back up of "stuff") but now KDE doesn't like it - complaining that the file system is a problem
Comment 25 YAFU 2018-03-25 18:29:48 UTC
Currently 5.12 or 5.44 plasma packages in Kubuntu 18.04.
=====
I have this problem when trying to mount any removable device or internal disk partition, either from Dolphin or from removable device manager in panel. It always shows an error message when you try to mount the device first time, the device is not opened in Dolphin but it is mounted correctly. Then at the second attempt it does not show error message and device is opened in Dolphin.
The messages that I get in Spanish:
From Dolphin:
"Ocurrió un error al acceder a «Carpeta personal», el sistema respondió: El dispositivo ya está montado: Device /dev/sdb3 is already mounted at `/media/yafu/PART 1'."

From removable device manager in panel a window message titled "Error Cliente KIO ?" and "Formato de URL erroneo" message.

By the way, in a recent Dolphin update, when you mount partitions from the small     folder/home icon to the left of the Dolphin address bar (that icon only appears if you have Panels > Places disabled), every time you Mount a device from there that menu is filled enormously with "Umount <<Partition X>>" items. Really annoying.
Comment 26 Xwang 2018-04-02 17:03:37 UTC
I have the same issue in archlinux.
Comment 27 Attila 2018-04-06 06:42:59 UTC
Additional info:

I think I can explain this bug. The device notifier is trying to mount the USB-Device and calls immediately dolphin. At this time the USB-Device is still not mounted. The mount procedure is not done and Dolphin wants to show the mounted device. This is obviously a "timing" issue. In my opinion the device notifier MUST wait until the USB-Device is mounted before it calls Dolphin.

One more thing:
Before I click "Open with File Manager" I click on that little icon on the right side "Click to access this device from other applications". After that the USB-Device is mounted. Now I can click on "Open with File Manager" and Dolphin shows the USB-Device without any error message.
Comment 28 luca 2018-04-06 09:21:48 UTC
(In reply to Attila from comment #27)
> Additional info:
> 
> I think I can explain this bug. The device notifier is trying to mount the
> USB-Device and calls immediately dolphin. 

changing /usr/share/solid/actions/test-predicate-openinwindow.desktop

Exec=kde-open5 "%f"

in 

Exec=/bin/sleep 1; kde-open5 "%f"

helps?
Comment 29 Attila 2018-04-06 11:15:22 UTC
Unfortunately it doesn't help (even sleep for 10 seconds), but you got me to try one more thing because I was curious.

I have changed the line to

Exec=/usr/bin/kdialog --msgbox "%f"; kde-open5 "%f"

because I wanted to see what argument is passed to kde-open5.
The result is that the argument is empty, when I click on "Open with File Manager" for the first time and the error message appears.
When I click again on "Open with File Manager" the argument is like

/run/media/MY_USER_NAME/dae9aaff-533c-40e0-ab5c-70d231620ad0/

and Dolphin shows the USB-Device without any error message. At this time the USB-Device is already mounted.

I don't know anything about kde-open5. Does the call to mount a device happen in this application?

Any idea? Can I try something else?
Comment 30 luca 2018-04-06 12:25:36 UTC
(In reply to Attila from comment #29)
> Unfortunately it doesn't help (even sleep for 10 seconds)

I have done so many tests that can be confused, but here it seems to work ;)

Exec=/bin/sleep 0.5; [ ! -z "%f" ] && kde-open5 "%f"

if I receive an empty file name do nothing.


> I don't know anything about kde-open5. Does the call to mount a device
> happen in this application?

No, I don't think. 
If you change Exec in
Exec=/bin/sleep 10
devices are mounted anyway

It only opens file or URL with right applications.
-------------------------------------------------------------------
$ kde-open5 --help
Usage: kde-open5 [options] urls...
Command-line tool for network-transparent operations
Arguments:
  url                        file or URL
-------------------------------------------------------------------
Comment 31 Attila 2018-04-06 13:57:19 UTC
I have changed the line to

Exec=/bin/sleep 0.5; [ ! -z "%f" ] && kde-open5 "%f"

When I click on "Open with File Manager" for the first time then nothing happens. That was the intention of [ ! -z "%f" ].

When I click on "Open with File Manager" for the second time then Dolphin shows the USB-Device without any error message but it doesn't solve the issue. In any case I have to click twice on "Open with File Manager" to see the USB-Device.
By the way you are right. The call to mount a device doesn't happen in kde-open5.

Questions:
1. What distribution do you have, because it seems to work on your machine?

2. Would you mind it to install Fedora 27 to give it a try? In this case you can easily commit and investigate this bug.

I would appreciate any suggestion.
Comment 32 luca 2018-04-06 14:18:21 UTC
(In reply to Attila from comment #31)
> ...but it doesn't solve the issue. 

Sure, it's only a workaround( and it seems not working for all :( )
I'm only a simple user, not a dev. 

Debian testing
Plasma 5.12.4
Kf 5.44.0
Qt 5.9.2
Comment 33 Attila 2018-04-06 14:58:32 UTC
(In reply to luca from comment #32)
> (In reply to Attila from comment #31)

> Sure, it's only a workaround( and it seems not working for all :( )
> I'm only a simple user, not a dev. 

Sorry, I thought that you are a developer. I am a user too.

TO THE DEVELOPERS OUT THERE:

Could some one PLEASE take care of this bug, commit and fix it? It is so easy to reproduce it. PLEASE.
Comment 34 ed.shornock 2018-04-06 15:15:26 UTC
(In reply to luca from comment #32)
> (In reply to Attila from comment #31)
> > ...but it doesn't solve the issue. 
> 
> Sure, it's only a workaround( and it seems not working for all :( )
> I'm only a simple user, not a dev. 
> 
> Debian testing
> Plasma 5.12.4
> Kf 5.44.0
> Qt 5.9.2

I'm also using Debian testing/unstable and the sleep workaround doesn't work for me either.

Setting 

Exec=[ ! -z "%f" ] && kde-open5 "%f"

makes this slightly less annoying. I still have to click twice to access the mounted device but I don't get the error to click away
Comment 35 luca 2018-04-06 15:37:31 UTC
(In reply to ed.shornock from comment #34)
> 
> I'm also using Debian testing/unstable and the sleep workaround doesn't work
> for me either.
> 

not always working for me too :(
Comment 36 Paul 2018-04-06 17:13:27 UTC
https://github.com/storaged-project/udisks/issues/502

possibly relevant...
Comment 37 ed.shornock 2018-04-06 18:33:26 UTC
(In reply to Paul from comment #36)
> https://github.com/storaged-project/udisks/issues/502
> 
> possibly relevant...

Good find!

I rebuilt udisks2 without libmount enabled and this annoying bug has gone away.
Comment 38 Attila 2018-04-09 13:20:27 UTC
This is my workaround for those who don't want to recompile udisks2 on Fedora 27:

I have downloaded this two rpm's for Fedora 26:

  - udisks2-2.6.5-4.fc26.x86_64.rpm
  - libudisks2-2.6.5-4.fc26.i686.rpm

Then I did a downgrade in a "konsole" as root like this:

dnf downgrade udisks2-2.6.5-4.fc26.x86_64.rpm libudisks2-2.6.5-4.fc26.i686.rpm

This is it. Just plug in your USB-Device. You don't need to logout or reboot. It works immediately.
Of course don't forget to exclude this two rpm's before you do an update or they will be updated and the bug is back. This is just a temporary solution.
Comment 39 Glut 2018-04-16 12:32:09 UTC
I can confirm this issue on the Kubuntu 18.04 development release, updated as of 2018-04-16.

Additional information:

$ policy udisks2 libudisks2-0
udisks2:
  Installiert:           2.7.6-2ubuntu6
  Installationskandidat: 2.7.6-2ubuntu6
  Versionstabelle:
 *** 2.7.6-2ubuntu6 500
        500 http://de.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
libudisks2-0:
  Installiert:           2.7.6-2ubuntu6
  Installationskandidat: 2.7.6-2ubuntu6
  Versionstabelle:
 *** 2.7.6-2ubuntu6 500
        500 http://de.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status


KDE Frameworks: 5.44.0
Qt: 5.9.4
Locale: German

----------

As others have pointed out above, the Exec line does get rid of the error message, but forces me to click twice to mount the device (which is definitely preferable to having to deal with the error).

I tried downgrading my udisks2 packages to 2.6.5-2ubuntu2, but ran into dependency issues and had to abort that experiment.

A fix for this would be really appreciated. It seems to affect a significant number of installations and is very detrimental to the user experience. Having new users who have just installed their KDE distro of choice be presented with an error message like this after they've inserted their first USB device really doesn't shine a positive light on the DE, and might make some people second-guess their choice.
Comment 40 Mariusz Libera 2018-05-01 15:42:36 UTC
Created attachment 112348 [details]
device notifier workaround

I've spend some time looking into this and found out that the issue is not with the Device Notifier itself but with Solid, or with how Solid interacts with Udisks. I don't really know what's the source of the bug but I've come up with a workaround that fixes Device Notifier (so far it's working as expected for me). If anyone wants to try it out, you have to rebuild plasma-workspace with the attached patch applied. It fixes only Device Notifier, mounting with Dolphin is still broken as it seems to be calling Solid in a different way.
Comment 41 Nate Graham 2018-05-01 16:25:49 UTC
Thank you for the patch! Patches in bug reports tend to get lost, so would you mind submitting it using Phabricator? http://phabricator.kde.org/

Here is the documentation: https://community.kde.org/Infrastructure/Phabricator
Comment 42 David Edmundson 2018-05-01 18:47:16 UTC
Can one of you run 
" sudo dbus-monitor --system   > someLogFile " 

reproduce the bug, and attach that here please.
Comment 43 Xwang 2018-05-01 18:52:34 UTC
Created attachment 112354 [details]
Requested dbus-monitor.log

Here you are
Comment 44 Patrick Silva 2018-05-01 19:46:16 UTC
Created attachment 112357 [details]
dbus-monitor log on Arch Linux, plasma 5.12.5
Comment 45 David Edmundson 2018-05-01 20:26:12 UTC
So reading that log:

we mount at line 5871
that replies on line 6163

MountPoints emits it's property has changed on line 6965.

after we've signalled setupDone on the solid side.


Which maps perfectly to what Mariusz did in his workaround.

Udisks Mount does actually return the mounted path on success, so udisks really isn't at fault it is. It's just that solid ignores that returned value as it listens to the PropertiesChanged signal, but then things get out of sync.  I think patching solid is pretty feasible.
Comment 46 David Edmundson 2018-05-01 20:26:31 UTC
For clarity my line numbers are against #43
Comment 47 David Edmundson 2018-05-01 20:37:06 UTC
Somewhat blind patch https://phabricator.kde.org/P202 against solid.

It matches what the bug is, but I'm not able to test it.
Could one of you?
Comment 48 Mariusz Libera 2018-05-01 20:57:56 UTC
I've tested it with a couple of pendrives and an external usb drive, everything functions properly - accessing devices from Device Notifier and from Dolphin works without errors. Awesome work, thanks for fixing it. :)
Comment 49 David Edmundson 2018-05-01 21:02:55 UTC
Your patch helped. It's a lot easier when someone explains a bug in a dev readable format.

Will submit for review, thanks
Comment 50 David Edmundson 2018-05-02 12:49:10 UTC
Git commit d735708ff11c40ee6b9bee64544250d55067403f by David Edmundson.
Committed on 02/05/2018 at 12:48.
Pushed by davidedmundson into branch 'master'.

Update mount point after mount operations

Summary:
The order of udisks evaluation has changed from:

call Mount
propertiesChanged
mount call returns

call Mount
mount call returns
propertiesChanged

The mount has finished, but the property is not yet updated.

Solid caches properties, updating them when they change. This worked
before but due to the re-ordering client code gets "setupDone" requests
the mount point gets an outdated version from the cache and we get
errors. Invalidating the cache causes us to round-trip to the udisks
daemon meaning we'll have the correct values.

Test Plan:
Diagnosed but with dbus-monitor trace
Asked someone on the bug report to test this

Reviewers: #plasma

Subscribers: #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D12648

M  +7    -0    src/solid/devices/backends/udisks2/udisksdevice.cpp
M  +1    -0    src/solid/devices/backends/udisks2/udisksdevice.h
M  +4    -4    src/solid/devices/backends/udisks2/udisksstorageaccess.cpp

https://commits.kde.org/solid/d735708ff11c40ee6b9bee64544250d55067403f
Comment 51 Patrick Silva 2018-05-02 16:00:48 UTC
Patch was already applied on Arch Linux and the problem is really fixed.

Thank you all.
Comment 52 Nate Graham 2018-05-04 14:06:01 UTC
*** Bug 391386 has been marked as a duplicate of this bug. ***
Comment 53 Canoe 2018-05-14 19:39:44 UTC
A quick note that this also occurs for external LUKS encrypted drives mounted via USB, - potentially the same bug. Will review in further releases.
Comment 54 Patrick Silva 2018-06-14 16:18:43 UTC
*** Bug 395065 has been marked as a duplicate of this bug. ***
Comment 55 Claudio 2019-09-06 13:39:53 UTC
Kubuntu 18.04.3 LTS still has this annoying bug. solid version 5.44
Comment 56 Nate Graham 2019-09-06 13:51:55 UTC
There is nothing KDE can do about that. You should contact the Kubuntu people about it. See for example the related request for another Solid backport: https://phabricator.kde.org/T9525
Comment 57 gedakc 2020-03-23 18:46:47 UTC
For Kubuntu 18.04 users:

I created a PPA that has the patch in post #50 applied to the current Kubuntu 18.04 solid package. See:

https://launchpad.net/~gedakc/+archive/ubuntu/solid-1804-ppa

In my testing the updated packages in my PPA did indeed fix the problem as described in this bug report.