Skip to content

Forward host timezone to guest shell - #19

Merged
semistrict merged 1 commit into
mainfrom
claude/zealous-poitras-aaea2e
Jul 3, 2026
Merged

Forward host timezone to guest shell#19
semistrict merged 1 commit into
mainfrom
claude/zealous-poitras-aaea2e

Conversation

@semistrict

Copy link
Copy Markdown
Owner

Summary

The lnx guest shell defaulted to UTC even when the host was in another timezone. $TZ was already forwarded to guest execs when set, but macOS hosts rarely set it — the timezone lives in the /etc/localtime symlink, not the environment.

When $TZ is unset, forwarded_exec_env now falls back to detecting the host zone: it resolves /etc/localtime (e.g. …/zoneinfo/America/New_York), with /etc/timezone as a Debian fallback, and injects it as TZ for every guest exec including the login shell. Deterministic mode still pins TZ=UTC.

Test plan

  • Unit test zone_from_localtime_target_parses_zoneinfo_paths covers the symlink-target parsing (passes via bun run test).
  • End-to-end on a fresh instance: lnx run -- sh -c 'echo TZ=$TZ; date' now prints TZ=America/New_York / EDT, where before the guest reported UTC.

Notes

  • The fix is computed in the long-lived host broker process, so an already-running instance's broker must restart before it picks up the change.

The guest defaulted to UTC because macOS hosts rarely set $TZ; the
timezone lives in the /etc/localtime symlink instead. When $TZ is unset,
resolve the host zone from /etc/localtime (with /etc/timezone as the
Debian fallback) and inject it as TZ for guest execs. Deterministic mode
still pins TZ=UTC.
@semistrict
semistrict merged commit e2dffc5 into main Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant