Bug 498011 - Unexpected error message on local install: cmake -E touch: failed to update "/usr/local/share/icons/hicolor".
Summary: Unexpected error message on local install: cmake -E touch: failed to update "...
Status: RESOLVED NOT A BUG
Alias: None
Product: extra-cmake-modules
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.9.0
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: ecm-bugs-null@kde.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-29 11:03 UTC by Adrián Chaves (Gallaecio)
Modified: 2024-12-30 06:40 UTC (History)
0 users

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


Attachments
CMakeLists.txt file (263 bytes, text/plain)
2024-12-29 11:03 UTC, Adrián Chaves (Gallaecio)
Details
Bash script to reproduce the issue with the CMakeLists.txt file also attached (235 bytes, application/x-shellscript)
2024-12-29 11:04 UTC, Adrián Chaves (Gallaecio)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adrián Chaves (Gallaecio) 2024-12-29 11:03:16 UTC
Created attachment 176946 [details]
CMakeLists.txt file

I’ve attached a minimal reproducible example.

When running CMake for a local installation, I get an error about trying to create a global hicolor folder. It is my understanding that creating should folder should not even be attempted in the first place in this scenario.

On the bright side, the icon installation actually works as expected, it’s only the annoyance of getting this error message and wondering if there’s something I am doing wrong.
Comment 1 Adrián Chaves (Gallaecio) 2024-12-29 11:04:04 UTC
Created attachment 176947 [details]
Bash script to reproduce the issue with the CMakeLists.txt file also attached
Comment 2 Adrián Chaves (Gallaecio) 2024-12-29 11:30:19 UTC
Reading https://invent.kde.org/documentation/develop-kde-org/-/issues/195, the issue might be on the way cmake is called rather than on ECM.
Comment 3 Adrián Chaves (Gallaecio) 2024-12-29 11:38:45 UTC
With that change, though, a different error appears: `gtk-update-icon-cache: The generated cache was invalid.`
Comment 4 Christophe Marin 2024-12-29 12:45:17 UTC
Use `DESTDIR="~/.local" cmake --install build` instead.
Comment 5 Christophe Marin 2024-12-29 12:51:30 UTC
or `cmake -B build ----install-prefix ~/.local`  (needs cmake >= 3.21)
Comment 6 Adrián Chaves (Gallaecio) 2024-12-29 16:25:07 UTC
`DESTDIR=~/.local cmake --install build` is I think the way you would do it during packaging, e.g. in an Arch Linux PKGBUILD file, when you are temporarily installing the files into some dir (e.g. `pkgsrc` in Arch), but they are meant to end up installed onto a different dir (e.g. system-wide).

`cmake -B build --install-prefix ~/.local` seems to work the same as `cmake -B build/ -DCMAKE_INSTALL_PREFIX=~/.local`, but it is cleaner, so I’ll take it, and suggest it for the docs.

Still, this changes the issue, rather than solving it. Before I got `cmake -E touch: failed to update "/usr/local/share/icons/hicolor"`, now I get `gtk-update-icon-cache: The generated cache was invalid.`. Since it is also icon-related, I assume it might be also tied to ECM’s icon handling, although maybe the issue is in some upstream?
Comment 7 Christophe Marin 2024-12-29 17:59:49 UTC
(In reply to Adrián Chaves (Gallaecio) from comment #6)
> 
> `cmake -B build --install-prefix ~/.local` seems to work the same as `cmake
> -B build/ -DCMAKE_INSTALL_PREFIX=~/.local`, but it is cleaner, so I’ll take
> it, and suggest it for the docs.
> 
Considering CMake 3.16 is the current minimum version, documentation should suggest using `cmake -S . -B <build dir> -DCMAKE_INSTALL_PREFIX=<install location>` instead.

> Still, this changes the issue, rather than solving it. Before I got `cmake
> -E touch: failed to update "/usr/local/share/icons/hicolor"`, now I get
> `gtk-update-icon-cache: The generated cache was invalid.`. Since it is also
> icon-related, I assume it might be also tied to ECM’s icon handling,
> although maybe the issue is in some upstream?

The problem is your installation prefix. You shouldn't install in ~/.local or you must make sure all icons present in this folder won't be rejected by gtk-update-icon-cache.

e.g: does `find ~/.local/share/icons -type f |grep -E '.*\s/*'` return anything?
Comment 8 Adrián Chaves (Gallaecio) 2024-12-30 06:40:40 UTC
> You[…] must make sure all icons present in this folder won't be rejected by gtk-update-icon-cache. e.g: does `find ~/.local/share/icons -type f |grep -E '.*\s/*'` return anything?

I see, thanks.

I did have icons with spaces in their names. Removing it did not prevent the error message from `gtk-update-icon-cache`, but now that I know it is a system-specific issue, I’ll figure out what other icons are an issue.

Let’s mark this as resolved.