GNU bug report logs - #35594
GNOME: Application icons are not displayed immediately after installation

Previous Next

Package: guix;

Reported by: sirgazil <sirgazil <at> zoho.com>

Date: Sun, 5 May 2019 23:20:01 UTC

Severity: important

Merged with 36376, 41298

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35594 in the body.
You can then email your comments to 35594 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Sun, 05 May 2019 23:20:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to sirgazil <sirgazil <at> zoho.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sun, 05 May 2019 23:20:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: sirgazil <sirgazil <at> zoho.com>
To: "bug-guix" <bug-guix <at> gnu.org>
Subject: GNOME: Application icons are not displayed immediately after
 installation
Date: Sun, 05 May 2019 18:19:11 -0500
Hi,

I installed the GNU system in a real machine using Guix 1.0 ISO installer (https://ftp.gnu.org/gnu/guix/guix-system-install-1.0.0.x86_64-linux.iso.xz).

Whenever I install a desktop application, the application icon does not show up immediately in the list of available applications. I have to log out and log in again to be able to see it.


## Steps to reproduce

1. Install a desktop application (I tried GIMP, Scribus, Inkscape, Audacity)
2. Click on "Activities".
3. Click on "Show Applications" (the button with nine dots).


## Unexpected result

The icon of the installed application is not in the list.


## Expected result.

The icon of the installed application is in the list.


---
https://sirgazil.bitbucket.io/







Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Mon, 06 May 2019 02:24:01 GMT) Full text and rfc822 format available.

Message #8 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: sirgazil <sirgazil <at> zoho.com>
Cc: 35594 <at> debbugs.gnu.org
Subject: Re: bug#35594: GNOME: Application icons are not displayed immediately
 after installation
Date: Sun, 05 May 2019 22:21:59 -0400
Hi,

sirgazil <sirgazil <at> zoho.com> writes:

> I installed the GNU system in a real machine using Guix 1.0 ISO
> installer
> (https://ftp.gnu.org/gnu/guix/guix-system-install-1.0.0.x86_64-linux.iso.xz).
>
> Whenever I install a desktop application, the application icon does
> not show up immediately in the list of available applications. I have
> to log out and log in again to be able to see it.

Indeed, this has always been the case on Guix, and I agree it would be
good to fix it.  FWIW, another way to refresh the list of available
applications from GNOME Shell is to type: Alt-F2, and then enter the
single letter "r" as the command.  That should restart GNOME Shell
without affecting your other applications.  (Unfortunately for me, this
only works under Xorg, not Wayland.)

A related issue is that if you upgrade a program in Guix, and then
launch it using GNOME Shell, it will launch the old one.  That's because
our installed desktop files are specifically rewritten to launch the
program via an absolute path name /gnu/store/xxxxx/bin/* instead of
simply looking in PATH, and GNOME Shell continues to use the old desktop
files until it's restarted.  This was implemented back in 2016, here:

  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=d31860b9de07810e114490db5cc160a8b078c58d

I remember thinking it was a bad idea at the time, but I didn't have
enough energy to speak up about it.

      Mark




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Mon, 06 May 2019 11:36:02 GMT) Full text and rfc822 format available.

Message #11 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: sirgazil <sirgazil <at> zoho.com>
To: "Mark H Weaver" <mhw <at> netris.org>
Cc: 35594 <35594 <at> debbugs.gnu.org>
Subject: Re: bug#35594: GNOME: Application icons are not displayed
 immediately after installation
Date: Mon, 06 May 2019 06:34:40 -0500
---- On Sun, 05 May 2019 21:21:59 -0500 Mark H Weaver <mhw <at> netris.org> wrote ----

 > Hi, 
 >  
 > sirgazil <sirgazil <at> zoho.com> writes: 
 >  
 > > I installed the GNU system in a real machine using Guix 1.0 ISO 
 > > installer 
 > > (https://ftp.gnu.org/gnu/guix/guix-system-install-1.0.0.x86_64-linux.iso.xz). 
 > > 
 > > Whenever I install a desktop application, the application icon does 
 > > not show up immediately in the list of available applications. I have 
 > > to log out and log in again to be able to see it. 
 >  
 > Indeed, this has always been the case on Guix, and I agree it would be 
 > good to fix it.  FWIW, another way to refresh the list of available 
 > applications from GNOME Shell is to type: Alt-F2, and then enter the 
 > single letter "r" as the command.  That should restart GNOME Shell 
 > without affecting your other applications.  (Unfortunately for me, this 
 > only works under Xorg, not Wayland.) 
 >  
 > A related issue is that if you upgrade a program in Guix, and then 
 > launch it using GNOME Shell, it will launch the old one.  That's because 
 > our installed desktop files are specifically rewritten to launch the 
 > program via an absolute path name /gnu/store/xxxxx/bin/* instead of 
 > simply looking in PATH, and GNOME Shell continues to use the old desktop 
 > files until it's restarted.  This was implemented back in 2016, here: 
 >  
 >  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=d31860b9de07810e114490db5cc160a8b078c58d 
 >  
 > I remember thinking it was a bad idea at the time, but I didn't have 
 > enough energy to speak up about it. 


I see... Thanks for the information, Mark.





Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 03 Nov 2020 17:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: sirgazil <sirgazil <at> zoho.com>
Cc: ludo <at> gnu.org, 35594 <at> debbugs.gnu.org
Subject: Re: bug#35594: GNOME: Application icons are not displayed
 immediately after installation
Date: Tue, 03 Nov 2020 12:44:58 -0500
Hello,

sirgazil <sirgazil <at> zoho.com> writes:

> Hi,
>
> I installed the GNU system in a real machine using Guix 1.0 ISO
> installer
> (https://ftp.gnu.org/gnu/guix/guix-system-install-1.0.0.x86_64-linux.iso.xz).
>
> Whenever I install a desktop application, the application icon does
> not show up immediately in the list of available applications. I have
> to log out and log in again to be able to see it.
>
>
> ## Steps to reproduce
>
> 1. Install a desktop application (I tried GIMP, Scribus, Inkscape, Audacity)
> 2. Click on "Activities".
> 3. Click on "Show Applications" (the button with nine dots).
>
>
> ## Unexpected result
>
> The icon of the installed application is not in the list.
>
>
> ## Expected result.
>
> The icon of the installed application is in the list.

After asking in the #gnome channel on freenode, the problem is likely
caused by GNOME Shell using inotify to watch the $XDG_DATA_DIRS
referenced $HOME/.guix-profile/share/applications directory.   The
problem is that the inode of such directory will never change, as it
points to the current profile under /gnu/store:

--8<---------------cut here---------------start------------->8---
$ ls -id $HOME/.guix-profile/share/applications
72653730 /home/maxim/.guix-profile/share/applications/
maxim <at> hurd ~/src/guix$ realpath $HOME/.guix-profile/share/applications
/gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
maxim <at> hurd ~/src/guix$ ls -id /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
72653730 /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications/
--8<---------------cut here---------------end--------------->8---

Any applications making use of inotify to discover changes (to plugins,
for example) is at risk of having the same problem in Guix.

I don't currently have an idea of how we can fix this.

Maxim




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 03 Nov 2020 19:15:01 GMT) Full text and rfc822 format available.

Message #17 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: sirgazil <sirgazil <at> zoho.com>
Cc: ludo <at> gnu.org, 35594 <at> debbugs.gnu.org
Subject: Re: bug#35594: GNOME: Application icons are not displayed
 immediately after installation
Date: Tue, 03 Nov 2020 14:14:09 -0500
Hello,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> After asking in the #gnome channel on freenode, the problem is likely
> caused by GNOME Shell using inotify to watch the $XDG_DATA_DIRS
> referenced $HOME/.guix-profile/share/applications directory.   The
> problem is that the inode of such directory will never change, as it
> points to the current profile under /gnu/store:
>
> $ ls -id $HOME/.guix-profile/share/applications
> 72653730 /home/maxim/.guix-profile/share/applications/
> maxim <at> hurd ~/src/guix$ realpath $HOME/.guix-profile/share/applications
> /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
> maxim <at> hurd ~/src/guix$ ls -id /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
> 72653730 /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications/
>
> Any applications making use of inotify to discover changes (to plugins,
> for example) is at risk of having the same problem in Guix.
>
> I don't currently have an idea of how we can fix this.

Watching of the directory is done via Glib's GAppInfoMonitor
(gpio/gdesktopappinfo.c).  A suggested idea from #gnome-shell would be
to patch its desktop_file_dir_init() procedure with Guix-specifics; I
don't know *how* yet.  The folks in #gtk may provide some clues.

Maxim




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 03 Nov 2020 22:34:02 GMT) Full text and rfc822 format available.

Message #20 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: sirgazil <sirgazil <at> zoho.com>
Cc: ludo <at> gnu.org, 35594 <at> debbugs.gnu.org
Subject: Re: bug#35594: GNOME: Application icons are not displayed
 immediately after installation
Date: Tue, 03 Nov 2020 17:33:18 -0500
Hi again,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> Hello,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:
>
>> After asking in the #gnome channel on freenode, the problem is likely
>> caused by GNOME Shell using inotify to watch the $XDG_DATA_DIRS
>> referenced $HOME/.guix-profile/share/applications directory.   The
>> problem is that the inode of such directory will never change, as it
>> points to the current profile under /gnu/store:
>>
>> $ ls -id $HOME/.guix-profile/share/applications
>> 72653730 /home/maxim/.guix-profile/share/applications/
>> maxim <at> hurd ~/src/guix$ realpath $HOME/.guix-profile/share/applications
>> /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
>> maxim <at> hurd ~/src/guix$ ls -id /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications
>> 72653730 /gnu/store/ph6a7fy735w5nycmf3za77m6v3g0r7xb-profile/share/applications/
>>
>> Any applications making use of inotify to discover changes (to plugins,
>> for example) is at risk of having the same problem in Guix.
>>
>> I don't currently have an idea of how we can fix this.
>
> Watching of the directory is done via Glib's GAppInfoMonitor
> (gpio/gdesktopappinfo.c).  A suggested idea from #gnome-shell would be
> to patch its desktop_file_dir_init() procedure with Guix-specifics; I
> don't know *how* yet.  The folks in #gtk may provide some clues.
>
> Maxim

I've analyzed the situation a bit; I'll explain the big lines of what I
think might be a solution.

The idea would be to patch desktop_file_dir_init() as mentioned earlier
with a procedure similar to desktop_file_dir_get_alternative_dir in that
same gdesktopappinfo.c file.  This new procedure would search for a
parent symlink of the dir argument (dir being one of the entries
constructed via XDG_DATA_DIRS, such as
$HOME/.guix-profile/share/applications.).

The algorithm for this new procedure would be like:

1. Check if a parent of DIR is a symlink.  When there are none, return
NULL.
2. Resolve the symlink parent until the last symlink, e.g. for symlink1
-> symlink2 -> directory, it saves symlink2.
3. Return the parent directory of the symlink resulting from 2 (i.e. dirname
symlink2).

In most cases (guix environment, build environment, extra user
profiles), the entries in XDG_DATA_DIRS are not symlinks but directly
store entries so there's nothing we can do about it.

The case of interest here is the default user profile or
$HOME/.guix-profile, which gets added to XDG_DATA_DIRS via /etc/profile
(on Guix System).  Because of the indirect links to the store, and the
mutable /var/guix/profiles/per-user/$USER directory used to store the
profile links, it is possible to have inotify work correctly.  The
algorithm described above would resolve $HOME/.guix-profile into
/var/guix/profiles/per-user/$USER, and /run/current-system into /run.

While adding a watch to /run is not optimal, it's not dramatic either
given the watch is not recursive and only watch for specific actions:

#define IP_INOTIFY_DIR_MASK
 (IN_MODIFY|IN_ATTRIB|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|IN_CREATE|IN_DELETE_SELF|IN_UNMOUNT|IN_MOVE_SELF|IN_CLOSE_WRITE)

(from gio/inotify/inotify-path.c)

Thoughts?

Thanks,

Maxim




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Wed, 04 Nov 2020 16:56:01 GMT) Full text and rfc822 format available.

Message #23 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: sirgazil <sirgazil <at> zoho.com>, 35594 <at> debbugs.gnu.org
Subject: Re: bug#35594: GNOME: Application icons are not displayed
 immediately after installation
Date: Wed, 04 Nov 2020 17:54:56 +0100
Hello!

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

> The case of interest here is the default user profile or
> $HOME/.guix-profile, which gets added to XDG_DATA_DIRS via /etc/profile
> (on Guix System).  Because of the indirect links to the store, and the
> mutable /var/guix/profiles/per-user/$USER directory used to store the
> profile links, it is possible to have inotify work correctly.  The
> algorithm described above would resolve $HOME/.guix-profile into
> /var/guix/profiles/per-user/$USER, and /run/current-system into /run.
>
> While adding a watch to /run is not optimal, it's not dramatic either
> given the watch is not recursive and only watch for specific actions:
>
> #define IP_INOTIFY_DIR_MASK
>  (IN_MODIFY|IN_ATTRIB|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|IN_CREATE|IN_DELETE_SELF|IN_UNMOUNT|IN_MOVE_SELF|IN_CLOSE_WRITE)
>
> (from gio/inotify/inotify-path.c)

I think our messages crossed.  :-)  I agree with your conclusions.  I
posted a preliminary patch following our discussion:

  https://issues.guix.gnu.org/36376#2

It’s only taking care of ~/.guix-profile, not /run, because I think
that’s the most common case.  (Usually you’d only add applications to
/run when reconfiguring, and then you may reboot shortly after in a
laptop kind of setting.  Also, one typically doesn’t *add* applications
to /run.)

Thoughts?

Ludo’.




Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 04 Nov 2020 20:55:01 GMT) Full text and rfc822 format available.

Merged 35594 36376. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 04 Nov 2020 20:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Wed, 04 Nov 2020 21:43:01 GMT) Full text and rfc822 format available.

Message #30 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Wed, 04 Nov 2020 16:41:58 -0500
Hello Ludovic and Leo,

Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> Hi Ludo,
>
> Am Dienstag, den 03.11.2020, 23:46 +0100 schrieb Ludovic Courtès:
>> Ludovic Courtès <ludo <at> gnu.org> skribis:
>> 
>> > This is not news to us, but as
>> > <https://distrowatch.com/weekly.php?issue=20190624#guixsd> notes,
>> > the
>> > application menu of desktop environments is not automatically
>> > updated
>> > when a package is installed or removed.  It’d be great if we could
>> > somehow notify the desktop environment.
>> 
>> We’ve investigated today on IRC with Maxim and Leo P. and here’s the
>> summary of our findings:
> Seeing my name thrown around more and more lately makes me blush a
> little.
>> [...]
>> 
>> The GLib patch below is an attempt to monitor ~/.guix-profile and to
>> treat changes to that symlink as if they were changes to
>> ~/.guix-profile/share/applications (which contains ‘.desktop’ files.)
>> It actually builds but I haven’t tested it yet.  :-)
>> 
>> WDYT?

Pretty cool!  It'd keep on working even if we even clean up /etc/profile
from the hardcoded defauts environment variables (say, if we merge one
of the proposed solution of https://issues.guix.gnu.org/22138).

> Not having tested it either, I think that we should also listen on
> /run/current-system/ (if it exists), so that changes to the system as
> done by `reconfigure` are picked up.  This includes most importantly
> changes to the GNOME ecosystem itself.

I agree that it seems useful and important to add a monitor on the
/run/current-system as well.

Thank you!

Maxim




Merged 35594 36376 41298. Request was from Maxim Cournoyer <maxim.cournoyer <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 04 Nov 2020 22:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 10 Nov 2020 15:25:01 GMT) Full text and rfc822 format available.

Message #35 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Tue, 10 Nov 2020 16:23:55 +0100
Hi Maxim,

So I went further to test the initial GLib patch I posted in “real
conditions”.

‘guix system vm-image’ takes an awful lot of time for big images; I
patiently waited for completion for an image of ‘desktop.tmpl’, but then
its root file system turned out to be too small for me to run ‘guix
install’.

So instead I tried this:

  1. ‘guix system vm desktop.tmpl’;

  2. ‘guix install inkscape -p /tmp/test’ on my actual machine;

  3. Start the GNOME VM created above;

  4. Inside the VM, search for Inkscape, notice it’s not there;

  5. Inside the VM, have ~/.guix-profile point to the profile created on
     the host above, and notice that Inkscape becomes available.

Video!

  mpv http://web.fdn.fr/~lcourtes/tmp/gnome-desktop-app-detection.webm

So I think we should include this fix in 1.2.  What do people think?

The main downside is extra grafting, which means extra disk and CPU
usage for our users.  However, libx11 (11K dependents) is also grafted,
so it shouldn’t make things worse (GLib has 6K dependents).

Maxim, did you have a variant of the GLib patch that also checks
/run/current-system?

Thanks,
Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 10 Nov 2020 17:50:02 GMT) Full text and rfc822 format available.

Message #38 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 36376 <at> debbugs.gnu.org, Leo Prikler <leo.prikler <at> student.tugraz.at>,
 35594 <at> debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Tue, 10 Nov 2020 18:48:53 +0100
On Tue, 10 Nov 2020 at 16:25, Ludovic Courtès <ludo <at> gnu.org> wrote:

> Video!

Héhé!  Nice :-)

> So I think we should include this fix in 1.2.  What do people think?

You mean only the initial patch.  If it works in "real conditions" for
bob on 'antelope' (desktop.tmpl), then it would nice to have for 1.2,


> The main downside is extra grafting, which means extra disk and CPU
> usage for our users.  However, libx11 (11K dependents) is also grafted,
> so it shouldn’t make things worse (GLib has 6K dependents).

No free lunch. :-)
Is it really slow or acceptable?


All the best,
simon




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 10 Nov 2020 21:24:01 GMT) Full text and rfc822 format available.

Message #41 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 36376 <at> debbugs.gnu.org, Leo Prikler <leo.prikler <at> student.tugraz.at>,
 35594 <at> debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Tue, 10 Nov 2020 22:23:21 +0100
Hi,

zimoun <zimon.toutoune <at> gmail.com> skribis:

> On Tue, 10 Nov 2020 at 16:25, Ludovic Courtès <ludo <at> gnu.org> wrote:

[...]

>> The main downside is extra grafting, which means extra disk and CPU
>> usage for our users.  However, libx11 (11K dependents) is also grafted,
>> so it shouldn’t make things worse (GLib has 6K dependents).
>
> No free lunch. :-)
> Is it really slow or acceptable?

If you’re installing a graphical applications, it’s already being
grafted, so the extra graft doesn’t make a difference.

Non-graphical applications that depend on GLib will now need to be
grafted, but I think there aren’t many of them, and they too might also
be grafted for other reasons.

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Thu, 12 Nov 2020 15:57:02 GMT) Full text and rfc822 format available.

Message #44 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Thu, 12 Nov 2020 16:56:07 +0100
[Message part 1 (text/plain, inline)]
Hi!

Ludovic Courtès <ludo <at> gnu.org> skribis:

> So I went further to test the initial GLib patch I posted in “real
> conditions”.

I did some more testing using a similar workflow: this time I repeatedly
changed the profile (installing/removing packages), which showed that
the first patch was buggy (it would only notice the creation of
~/.guix-profile and nothing beyond that).

This is in part due to the fact that ‘GFileMonitor’ follows symlinks (it
doesn’t pass the ‘IN_DONT_FOLLOW’ inotify flag).  Thus, when it monitors
~/.guix-profile, it’s really monitoring /gnu/store/…-profile, which
never changes.

So with this new patch it’s monitoring /var/guix/profiles/per-user/USER
and /var/guix/profiles instead, which correctly detects changes.  It
detects a bit “too much” (for instance, running ‘guix pull’ triggers the
inotify hook because it changes
/var/guix/profiles/per-user/USER/current-guix) but that’s probably OK.

If you’re using GNOME, Xfce, or another GLib-based desktop environment,
I’d welcome tests on the bare metal!  Just apply the patch on a checkout
of ‘master’ and run:

  sudo -E ./pre-inst-env guix system reconfigure …

If there are no objections, I’d like to apply this patch shortly so we
can go ahead with a last round of pre-release tests.

Ludo’.

[0001-gnu-glib-Graft-patch-to-detect-changes-to-the-instal.patch (text/x-patch, inline)]
From 7d03b2b823951219ece46c7f34e25ae36a8ba12c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo <at> gnu.org>
Date: Thu, 12 Nov 2020 16:35:24 +0100
Subject: [PATCH] gnu: glib: Graft patch to detect changes to the installed
 applications.

Fixes <https://bugs.gnu.org/35594>.
Reported by sirgazil <sirgazil <at> zoho.com> and others.

* gnu/packages/patches/glib-appinfo-watch.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/glib.scm (glib)[replacement]: New field.
(glib-with-gio-patch): New variable.
(glib-with-documentation): Use 'package/inherit'.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/glib.scm                         | 14 ++-
 gnu/packages/patches/glib-appinfo-watch.patch | 92 +++++++++++++++++++
 3 files changed, 105 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/glib-appinfo-watch.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d5a13cbdbd..2301a04d2f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1050,6 +1050,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ghostscript-no-header-id.patch		\
   %D%/packages/patches/ghostscript-no-header-uuid.patch		\
   %D%/packages/patches/ghostscript-no-header-creationdate.patch \
+  %D%/packages/patches/glib-appinfo-watch.patch			\
   %D%/packages/patches/glib-tests-timer.patch			\
   %D%/packages/patches/glibc-CVE-2018-11236.patch		\
   %D%/packages/patches/glibc-CVE-2018-11237.patch		\
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 901222476a..43523e516d 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -181,6 +181,7 @@ shared NFS home directories.")
   (package
    (name "glib")
    (version "2.62.6")
+   (replacement glib-with-gio-patch)
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnome/sources/"
@@ -387,11 +388,20 @@ dynamic loading, and an object system.")
    (home-page "https://developer.gnome.org/glib/")
    (license license:lgpl2.1+)))
 
+(define glib-with-gio-patch
+  ;; GLib with a fix for <https://bugs.gnu.org/35594>.
+  ;; TODO: Fold into 'glib' above in the next rebuild cycle.
+  (package
+    (inherit glib)
+    (source (origin
+              (inherit (package-source glib))
+              (patches (cons (search-patch "glib-appinfo-watch.patch")
+                             (origin-patches (package-source glib))))))))
+
 (define-public glib-with-documentation
   ;; glib's doc must be built in a separate package since it requires gtk-doc,
   ;; which in turn depends on glib.
-  (package
-    (inherit glib)
+  (package/inherit glib
     (properties (alist-delete 'hidden? (package-properties glib)))
     (outputs (cons "doc" (package-outputs glib))) ; 20 MiB of GTK-Doc reference
     (native-inputs
diff --git a/gnu/packages/patches/glib-appinfo-watch.patch b/gnu/packages/patches/glib-appinfo-watch.patch
new file mode 100644
index 0000000000..638a5e0949
--- /dev/null
+++ b/gnu/packages/patches/glib-appinfo-watch.patch
@@ -0,0 +1,92 @@
+This patch lets GLib's GDesktopAppInfo API watch and notice changes
+to the Guix user and system profiles.  That way, the list of available
+applications shown by the desktop environment is immediately updated
+when the user runs "guix install", "guix remove", or "guix system
+reconfigure" (see <https://issues.guix.gnu.org/35594>).
+
+It does so by monitoring /var/guix/profiles (for changes to the system
+profile) and /var/guix/profiles/per-user/USER (for changes to the user
+profile) and crawling their share/applications sub-directory when
+changes happen.
+
+diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
+index f1e2fdd..095c110 100644
+--- a/gio/gdesktopappinfo.c
++++ b/gio/gdesktopappinfo.c
+@@ -148,6 +148,7 @@ typedef struct
+   gchar                      *alternatively_watching;
+   gboolean                    is_config;
+   gboolean                    is_setup;
++  gchar                      *guix_profile_watch_dir;
+   GFileMonitor               *monitor;
+   GHashTable                 *app_names;
+   GHashTable                 *mime_tweaks;
+@@ -180,6 +181,7 @@ desktop_file_dir_unref (DesktopFileDir *dir)
+     {
+       desktop_file_dir_reset (dir);
+       g_free (dir->path);
++      g_free (dir->guix_profile_watch_dir);
+       g_free (dir);
+     }
+ }
+@@ -204,6 +206,13 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir)
+ {
+   gchar *parent;
+ 
++  /* If DIR is a profile, watch the specified directory--e.g.,
++   * /var/guix/profiles/per-user/$USER/ for the user profile.  Do not watch
++   * ~/.guix-profile or /run/current-system/profile because GFileMonitor does
++   * not pass IN_DONT_FOLLOW and thus cannot notice any change.  */
++  if (dir->guix_profile_watch_dir != NULL)
++    return g_strdup (dir->guix_profile_watch_dir);
++
+   /* If the directory itself exists then we need no alternative. */
+   if (g_access (dir->path, R_OK | X_OK) == 0)
+     return NULL;
+@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor      *monitor,
+    *
+    * If this is a notification for a parent directory (because the
+    * desktop directory didn't exist) then we shouldn't fire the signal
+-   * unless something actually changed.
++   * unless something actually changed or it's in /var/guix/profiles.
+    */
+   g_mutex_lock (&desktop_file_dir_lock);
+ 
+-  if (dir->alternatively_watching)
++  if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL)
+     {
+       gchar *alternative_dir;
+ 
+@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void)
+       for (i = 0; dirs[i]; i++)
+         g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
+ 
++      {
++        /* Monitor the system and user profile under /var/guix/profiles and
++         * treat modifications to them as if they were modifications to their
++         * /share sub-directory.  */
++        const gchar *user;
++        DesktopFileDir *system_profile_dir, *user_profile_dir;
++
++        system_profile_dir =
++          desktop_file_dir_new ("/var/guix/profiles/system/profile/share");
++        system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles");
++        g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir));
++
++        user = g_get_user_name ();
++        if (user != NULL)
++          {
++            gchar *profile_dir, *user_data_dir;
++
++            profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL);
++            user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL);
++            user_profile_dir = desktop_file_dir_new (user_data_dir);
++            user_profile_dir->guix_profile_watch_dir = profile_dir;
++            g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir));
++            g_free (user_data_dir);
++          }
++      }
++
+       /* The list of directories will never change after this, unless
+        * g_get_user_config_dir() changes due to %G_TEST_OPTION_ISOLATE_DIRS. */
+       desktop_file_dirs_config_dir = user_config_dir;
-- 
2.29.2


Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Fri, 13 Nov 2020 20:40:02 GMT) Full text and rfc822 format available.

Message #47 received at 35594-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 36376-done <at> debbugs.gnu.org,
 35594-done <at> debbugs.gnu.org
Subject: Re: bug#35594: bug#36376: Application menu of desktop environment
 not automatically updated
Date: Fri, 13 Nov 2020 21:38:41 +0100
Ludovic Courtès <ludo <at> gnu.org> skribis:

>>From 7d03b2b823951219ece46c7f34e25ae36a8ba12c Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo <at> gnu.org>
> Date: Thu, 12 Nov 2020 16:35:24 +0100
> Subject: [PATCH] gnu: glib: Graft patch to detect changes to the installed
>  applications.
>
> Fixes <https://bugs.gnu.org/35594>.
> Reported by sirgazil <sirgazil <at> zoho.com> and others.
>
> * gnu/packages/patches/glib-appinfo-watch.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/glib.scm (glib)[replacement]: New field.
> (glib-with-gio-patch): New variable.
> (glib-with-documentation): Use 'package/inherit'.

Pushed as ae10ec441aa524bf267f9cefd4a319b44d0b8b44 (version-1.2.0).

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 17 Nov 2020 04:58:01 GMT) Full text and rfc822 format available.

Message #50 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Mon, 16 Nov 2020 23:57:20 -0500
Hello Ludovic!

Ludovic Courtès <ludo <at> gnu.org> writes:

[...]

> So with this new patch it’s monitoring /var/guix/profiles/per-user/USER
> and /var/guix/profiles instead, which correctly detects changes.  It
> detects a bit “too much” (for instance, running ‘guix pull’ triggers the
> inotify hook because it changes
> /var/guix/profiles/per-user/USER/current-guix) but that’s probably OK.
>
> If you’re using GNOME, Xfce, or another GLib-based desktop environment,
> I’d welcome tests on the bare metal!  Just apply the patch on a checkout
> of ‘master’ and run:

I've now done so!  It works :-)!  I do have noticed something a bit off,
see the comments below.

[...]

> diff --git a/gnu/packages/patches/glib-appinfo-watch.patch b/gnu/packages/patches/glib-appinfo-watch.patch
> new file mode 100644
> index 0000000000..638a5e0949
> --- /dev/null
> +++ b/gnu/packages/patches/glib-appinfo-watch.patch
> @@ -0,0 +1,92 @@
> +This patch lets GLib's GDesktopAppInfo API watch and notice changes
> +to the Guix user and system profiles.  That way, the list of available
> +applications shown by the desktop environment is immediately updated
> +when the user runs "guix install", "guix remove", or "guix system
> +reconfigure" (see <https://issues.guix.gnu.org/35594>).
> +
> +It does so by monitoring /var/guix/profiles (for changes to the system
> +profile) and /var/guix/profiles/per-user/USER (for changes to the user
> +profile) and crawling their share/applications sub-directory when
> +changes happen.
> +
> +diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
> +index f1e2fdd..095c110 100644
> +--- a/gio/gdesktopappinfo.c
> ++++ b/gio/gdesktopappinfo.c
> +@@ -148,6 +148,7 @@ typedef struct
> +   gchar                      *alternatively_watching;
> +   gboolean                    is_config;
> +   gboolean                    is_setup;
> ++  gchar                      *guix_profile_watch_dir;
> +   GFileMonitor               *monitor;
> +   GHashTable                 *app_names;
> +   GHashTable                 *mime_tweaks;
> +@@ -180,6 +181,7 @@ desktop_file_dir_unref (DesktopFileDir *dir)
> +     {
> +       desktop_file_dir_reset (dir);
> +       g_free (dir->path);
> ++      g_free (dir->guix_profile_watch_dir);
> +       g_free (dir);
> +     }
> + }
> +@@ -204,6 +206,13 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir)
> + {
> +   gchar *parent;
> +
> ++  /* If DIR is a profile, watch the specified directory--e.g.,
> ++   * /var/guix/profiles/per-user/$USER/ for the user profile.  Do not watch
> ++   * ~/.guix-profile or /run/current-system/profile because GFileMonitor does
> ++   * not pass IN_DONT_FOLLOW and thus cannot notice any change.  */
> ++  if (dir->guix_profile_watch_dir != NULL)
> ++    return g_strdup (dir->guix_profile_watch_dir);
> ++
> +   /* If the directory itself exists then we need no alternative. */
> +   if (g_access (dir->path, R_OK | X_OK) == 0)
> +     return NULL;
> +@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor      *monitor,
> +    *
> +    * If this is a notification for a parent directory (because the
> +    * desktop directory didn't exist) then we shouldn't fire the signal
> +-   * unless something actually changed.
> ++   * unless something actually changed or it's in /var/guix/profiles.
> +    */
> +   g_mutex_lock (&desktop_file_dir_lock);
> +
> +-  if (dir->alternatively_watching)
> ++  if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL)
                                      ^^^^^^
                                      Why is this needed/desirable?

OK, I think I get it.  The API seems to imply that users (such as
gnome-shell) need to keep asking about a desktop directory entry as they
are otherwise "forgotten".  Since we are inserting entries at the level
of glib ourselves, these will never be asked for by gnome-shell, so must
not be cleared.  Is that correct?

> +     {
> +       gchar *alternative_dir;
> +
> +@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void)
> +       for (i = 0; dirs[i]; i++)
> +         g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
> +
> ++      {
> ++        /* Monitor the system and user profile under /var/guix/profiles and
> ++         * treat modifications to them as if they were modifications to their
> ++         * /share sub-directory.  */
> ++        const gchar *user;
> ++        DesktopFileDir *system_profile_dir, *user_profile_dir;
> ++
> ++        system_profile_dir =
> ++          desktop_file_dir_new ("/var/guix/profiles/system/profile/share");
> ++        system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles");
> ++        g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir));
> ++
> ++        user = g_get_user_name ();

This seems to get the user of the running glib application; e.g. for
GNOME Shell it returns 'gdm'...

> ++        if (user != NULL)
> ++          {
> ++            gchar *profile_dir, *user_data_dir;
> ++
> ++            profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL);
> ++            user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL);
> ++            user_profile_dir = desktop_file_dir_new (user_data_dir);
> ++            user_profile_dir->guix_profile_watch_dir = profile_dir;
> ++            g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir));
> ++            g_free (user_data_dir);
> ++          }
> ++      }
> ++

...which means the above puts the watch on the
"/var/guix/profiles/per-user/gdm" directory, which doesn't exist.

sudo strace -f -s200 -p$(pgrep gnome-shell | head -n1) reports entries
such as:

--8<---------------cut here---------------start------------->8---
92   00:48:47 poll([{fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=9, events=POLLIN}, {fd=19, events=POLLIN}, {fd=28, events=POLLIN}], 5, -1 <unfinished ...>
390   00:48:47 <... poll resumed>)      = 0 (Timeout)
390   00:48:47 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
390   00:48:47 poll([{fd=3, events=POLLIN}, {fd=17, events=POLLIN}], 2, 3996) = 0 (Timeout)
390   00:48:51 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
390   00:48:51 poll([{fd=3, events=POLLIN}, {fd=17, events=POLLIN}], 2, 3998) = 0 (Timeout)
390   00:48:55 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
--8<---------------cut here---------------end--------------->8---

The fallback mechanism should have been disabled in
desktop_file_dir_changed (dir->guix-profile_watch_dir != NULL so
desktop_file_dir_get_alternative_dir doesn't get called), so it seems
this shouldn't work.

Could it be that the watches used by glib implement a recursive
inotify-based watch and that it works because any changes under the
/var/guix/profiles directory get picked up, including those of user
profiles.  The sources seem to suggest so, for example in
gio/inotify/inotify-path.c.  If that is the case, it could lead to a new
interesting problems: applications from other users could end up being
shown inadvertently.

I'll try to validate the above hypothesis, but this takes time.

In any case, the current situation is already an improvement, so thank
you for your efforts!

Maxim




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Tue, 17 Nov 2020 09:09:02 GMT) Full text and rfc822 format available.

Message #53 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Tue, 17 Nov 2020 10:08:49 +0100
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
> [...]
>
>> So with this new patch it’s monitoring /var/guix/profiles/per-user/USER
>> and /var/guix/profiles instead, which correctly detects changes.  It
>> detects a bit “too much” (for instance, running ‘guix pull’ triggers the
>> inotify hook because it changes
>> /var/guix/profiles/per-user/USER/current-guix) but that’s probably OK.
>>
>> If you’re using GNOME, Xfce, or another GLib-based desktop environment,
>> I’d welcome tests on the bare metal!  Just apply the patch on a checkout
>> of ‘master’ and run:
>
> I've now done so!  It works :-)!  I do have noticed something a bit off,
> see the comments below.

Thanks for testing!

>> +@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor      *monitor,
>> +    *
>> +    * If this is a notification for a parent directory (because the
>> +    * desktop directory didn't exist) then we shouldn't fire the signal
>> +-   * unless something actually changed.
>> ++   * unless something actually changed or it's in /var/guix/profiles.
>> +    */
>> +   g_mutex_lock (&desktop_file_dir_lock);
>> +
>> +-  if (dir->alternatively_watching)
>> ++  if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL)
>                                       ^^^^^^
>                                       Why is this needed/desirable?

As the comment above states it, the ‘if’ is here so that the “changed”
signal is not fired when we’re just watching a parent directory.

However, in our case, ‘dir->alternatively_watching != NULL’ possibly
means that we’re watching a Guix profile, in which case we do want to
fire the “changed” signal.

This “&&” allows us to disambiguate between “watching a parent
directory” and “watching a Guix profile”.

>> +@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void)
>> +       for (i = 0; dirs[i]; i++)
>> +         g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
>> +
>> ++      {
>> ++        /* Monitor the system and user profile under /var/guix/profiles and
>> ++         * treat modifications to them as if they were modifications to their
>> ++         * /share sub-directory.  */
>> ++        const gchar *user;
>> ++        DesktopFileDir *system_profile_dir, *user_profile_dir;
>> ++
>> ++        system_profile_dir =
>> ++          desktop_file_dir_new ("/var/guix/profiles/system/profile/share");
>> ++        system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles");
>> ++        g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir));
>> ++
>> ++        user = g_get_user_name ();
>
> This seems to get the user of the running glib application; e.g. for
> GNOME Shell it returns 'gdm'...
>
>> ++        if (user != NULL)
>> ++          {
>> ++            gchar *profile_dir, *user_data_dir;
>> ++
>> ++            profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL);
>> ++            user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL);
>> ++            user_profile_dir = desktop_file_dir_new (user_data_dir);
>> ++            user_profile_dir->guix_profile_watch_dir = profile_dir;
>> ++            g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir));
>> ++            g_free (user_data_dir);
>> ++          }
>> ++      }
>> ++
>
> ...which means the above puts the watch on the
> "/var/guix/profiles/per-user/gdm" directory, which doesn't exist.

Yes, that profile is typically never populated.

> sudo strace -f -s200 -p$(pgrep gnome-shell | head -n1) reports entries
> such as:
>
> 92   00:48:47 poll([{fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=9, events=POLLIN}, {fd=19, events=POLLIN}, {fd=28, events=POLLIN}], 5, -1 <unfinished ...>
> 390   00:48:47 <... poll resumed>)      = 0 (Timeout)
> 390   00:48:47 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
> 390   00:48:47 poll([{fd=3, events=POLLIN}, {fd=17, events=POLLIN}], 2, 3996) = 0 (Timeout)
> 390   00:48:51 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
> 390   00:48:51 poll([{fd=3, events=POLLIN}, {fd=17, events=POLLIN}], 2, 3998) = 0 (Timeout)
> 390   00:48:55 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
>
> The fallback mechanism should have been disabled in
> desktop_file_dir_changed (dir->guix-profile_watch_dir != NULL so
> desktop_file_dir_get_alternative_dir doesn't get called), so it seems
> this shouldn't work.

What shouldn’t work?

We keep adding a watch on a non-existent directory, but I think that’s
fine.

> Could it be that the watches used by glib implement a recursive
> inotify-based watch and that it works because any changes under the
> /var/guix/profiles directory get picked up, including those of user
> profiles.  The sources seem to suggest so, for example in
> gio/inotify/inotify-path.c.  If that is the case, it could lead to a new
> interesting problems: applications from other users could end up being
> shown inadvertently.

We’re watching /var/guix/profiles (for the system profile) and
/var/guix/profiles/per-user/USER, but .desktop files are loaded from the
user’s own profile, so that should be fine.

Thanks a lot for looking into this!

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#35594; Package guix. (Wed, 18 Nov 2020 04:35:01 GMT) Full text and rfc822 format available.

Message #56 received at 35594 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 35594 <at> debbugs.gnu.org,
 36376 <at> debbugs.gnu.org
Subject: Re: bug#36376: Application menu of desktop environment not
 automatically updated
Date: Tue, 17 Nov 2020 23:34:42 -0500
Hello Ludovic!

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>
>> Ludovic Courtès <ludo <at> gnu.org> writes:

[...]

>>> +@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor      *monitor,
>>> +    *
>>> +    * If this is a notification for a parent directory (because the
>>> +    * desktop directory didn't exist) then we shouldn't fire the signal
>>> +-   * unless something actually changed.
>>> ++   * unless something actually changed or it's in /var/guix/profiles.
>>> +    */
>>> +   g_mutex_lock (&desktop_file_dir_lock);
>>> +
>>> +-  if (dir->alternatively_watching)
>>> ++  if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL)
>>                                       ^^^^^^
>>                                       Why is this needed/desirable?
>
> As the comment above states it, the ‘if’ is here so that the “changed”
> signal is not fired when we’re just watching a parent directory.
>
> However, in our case, ‘dir->alternatively_watching != NULL’ possibly
> means that we’re watching a Guix profile, in which case we do want to
> fire the “changed” signal.
>
> This “&&” allows us to disambiguate between “watching a parent
> directory” and “watching a Guix profile”.

Yes, this makes sense.  I got confused by the wording of the (existing)
comment that mentions "unless something actually changed".  I used to
think this meant the contents of whatever directory is being watched,
but looking more closely, it's really just about if the parent directory
of a non-existing data directory changed...  Makes senses, we don't want
that.

>>> +@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void)
>>> +       for (i = 0; dirs[i]; i++)
>>> +         g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
>>> +
>>> ++      {
>>> ++        /* Monitor the system and user profile under /var/guix/profiles and
>>> ++         * treat modifications to them as if they were modifications to their
>>> ++         * /share sub-directory.  */
>>> ++        const gchar *user;
>>> ++        DesktopFileDir *system_profile_dir, *user_profile_dir;
>>> ++
>>> ++        system_profile_dir =
>>> ++          desktop_file_dir_new ("/var/guix/profiles/system/profile/share");
>>> ++        system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles");
>>> ++        g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir));
>>> ++
>>> ++        user = g_get_user_name ();
>>
>> This seems to get the user of the running glib application; e.g. for
>> GNOME Shell it returns 'gdm'...
>>
>>> ++        if (user != NULL)
>>> ++          {
>>> ++            gchar *profile_dir, *user_data_dir;
>>> ++
>>> ++            profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL);
>>> ++            user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL);
>>> ++            user_profile_dir = desktop_file_dir_new (user_data_dir);
>>> ++            user_profile_dir->guix_profile_watch_dir = profile_dir;
>>> ++            g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir));
>>> ++            g_free (user_data_dir);
>>> ++          }
>>> ++      }
>>> ++
>>
>> ...which means the above puts the watch on the
>> "/var/guix/profiles/per-user/gdm" directory, which doesn't exist.
>
> Yes, that profile is typically never populated.

Ah, I now understand the source of my confusion; there are multiple
gnome-shell instances (components?) running, one apparently started by
the greeter (GDM), which doesn't have a profile, and others started by
the users which logged in.

Thanks again for the fix and explanations!

Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Dec 2020 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 124 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.