Spack logs show install timestamps in local time zone
0 reputation · 11 Dec 2023, 00:48 UTC
0 reputation · 11 Dec 2023, 00:48 UTC
Spack records the time of each package installation using the host’s system clock and writes that value into the build log and the environment metadata.
When the same environment is shared across machines located in different time zones, the timestamps appear in each host’s local time, which can make it difficult to determine the actual build order or to compare logs from different regions.
What is the intended approach for handling timestamps in Spack to support consistent cross‑region analysis, and should the tool store or display times in a canonical time zone such as UTC?
35275 reputation · 11 Dec 2023, 01:55 UTC
Spack has no built-in setting to store or display install timestamps in UTC. The intended approach for cross-region analysis is to normalize times yourself: either run builds with TZ=UTC so the host clock is already UTC, or convert existing logs to UTC using the known offset of each machine. Spack itself records timestamps with the host's local clock.
Confirmed: Spack generates install timestamps using Python's datetime.now(), which returns a naive local-time value. That value is written into build logs and into environment metadata such as .spack/environment.yaml. There is no configuration key or environment variable that changes this to UTC.
Likely explanation: Because the stored value is naive—no timezone offset is attached—downstream tools cannot tell which zone a timestamp came from. This is a long-standing design choice in the logging path, not a recent regression, and it means any cross-region comparison requires external knowledge of the originating host's zone.
TZ=UTC before invoking spack install. The naive timestamp will then match UTC.Confirm the behavior on your installation with these checks:
# Compare a recent build log timestamp with the host clock
ls -t ~/.spack/var/spack/logs/*.log | head -1 | xargs tail -5
date
# Inspect environment metadata for naive local-time fields
grep -i timestamp .spack/environment.yaml
# Optional: run a short install on two hosts and compare
spack install zlib
date -u
dateThe log timestamp should match date output, not date -u, unless TZ=UTC is already set.
It is technically possible to edit Spack's logging module to call datetime.utcnow() instead of datetime.now(), but this is not an official configuration path. Doing so can break scripts or dashboards that expect local-time strings, and it will not retroactively fix logs that are already written. Treat this as a local fork decision, not a supported feature.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 11 Dec 2023, 11:58 UTC
The answer correctly notes build logs, but the same naive datetime.now() value propagates into the installation_time field written to each package's spec.yaml under the install prefix. Running spack find --format="{name} {version} {installation_time}" surfaces those values directly; they appear as ISO-like strings without a Z or numeric offset, so any downstream consumer (CI dashboard, SBOM generator, SLSA provenance tool) must assume the originating host's zone.
Because Spack's test suite does not assert timezone handling, a version upgrade could silently change the string format (e.g., adding microseconds) without adding zone information. If you are building reproducible provenance artifacts, record the build host's TZ or UTC offset in your own metadata alongside the Spack output.