Incorrect timezone in Flatpak apps
Flatpak apps have incorrect timezone, their /etc/localtime
always points to /usr/share/zoneinfo/UTC
.
The reason, as I understand, is that Flatpak doesn't expose hosts /etc
, but recreates it inside the container. Looking at flatpak_get_timezone() code, the algorithm for timezone lookup is the following:
- Resolve the
/etc/localtime
symlink on the host - If
TZDIR
environment variable is set, and it matches/etc/localtime
destination prefix, return the suffix - Else, if
/etc/localtime
destination prefix is/usr/share/zoneinfo
, return the suffix - Else, if
/etc/timezone
exists, return its content. - Else, return
UTC
.
After that, as I understand, it recreates /etc/localtime
symlink in the container, pointing to /usr/share/zoneinfo/<derived-timezone>
.
Since Alpine's setup-timezone
creates zoneinfo file at /etc/zoneinfo/
and doesn't export TZDIR
, Flatpak doesn't find it and fallbacks to UTC. Exporting TZDIR=/etc/zoneinfo
fixes the issue.
I'm not sure which side to report it to, so for now this is more of a question than a bug report, and I reported it to Flatpak too. The question is whether there's any rigorous standard about it, and if there is, then according to it should Flatpak add /etc/zoneinfo
to the list of default locations, or should Alpine make sure TZDIR
is exported?
Also, if I understand correctly, Flatpak relies on host's /usr/share/zoneinfo
, so I guess tzdata
should be a dependency for flatpak
package, but I'm not sure in that.
The issue was originally discovered here.