gitbutlerapp/gitbutler · warning
system time is set before the Unix epoch
Error message
system time is set before the Unix epoch
What it means
now_ms() measures UNIX_EPOCH.elapsed() to get the current time in milliseconds and expects success. `Instant`-style elapsed from the epoch fails if the system clock is set before 1970-01-01, in which case the expect panics. It guards against a host clock misconfiguration.
Solutions
- Fix the system clock: run NTP/time sync (`timedatectl set-ntp true`, `ntpdate`, or correct date manually)
- Make now_ms fallible or clamp: use SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default()
- Log a warning when elapsed() fails instead of panicking, returning 0
Example fix
// before
fn now_ms() -> u128 {
UNIX_EPOCH
.elapsed()
.expect("system time is set before the Unix epoch")
.as_millis()
}
// after
fn now_ms() -> u128 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis()
} Defensive patterns
Strategy: fallback
Validate before calling
// Rust: check clock sanity before epoch math
fn clock_is_sane() -> bool {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.is_ok()
} Type guard
fn system_time_ms() -> Option<u128> {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.ok()
.map(|d| d.as_millis())
} Try / catch
match UNIX_EPOCH.elapsed() {
Ok(d) => d.as_millis(),
Err(_) => { tracing::warn!("system clock before Unix epoch"); 0 }
} Prevention
- Enable NTP time synchronization on hosts and VMs
- Check system clock settings when timestamps look wrong or app panics at startup
- Never assume the wall clock is post-1970; clamp or default elapsed time
When it happens
Trigger: Calling now_ms (used by askpass/git prompt handling) while the system clock is set to a time before the Unix epoch (negative elapsed time from UNIX_EPOCH).
Common situations: VMs or embedded systems with dead CMOS batteries booting at 1970 or earlier; manually mis-set system clocks; containers with incorrect clock sources.
Related errors
- a committed transaction always materializes a workspace
- anchor is always present in the order at this point
- AtSegment anchor always has oldest commit resolved
- broker already configured
- broker has not been configured
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/e1b6ff42c43c3fa4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-git/src/context.rs:332
.serialize(serializer)
}
fn remote_tracking_branch_parts(
repo: &gix::Repository,
branch: &gix::refs::FullNameRef,
) -> Result<(String, String)> {
let (remote, short_name) = extract_remote_name_and_short_name(branch, &repo.remote_names())
.ok_or_else(|| anyhow!("failed to determine remote and branch name for `{branch}`"))?;
let short_name = std::str::from_utf8(short_name.as_ref())
.context(format!("branch name for `{branch}` is not valid UTF-8"))?
.to_owned();
Ok((remote, short_name))
}
fn now_ms() -> u128 {
UNIX_EPOCH
.elapsed()
.expect("system time is set before the Unix epoch")
.as_millis()
}
async fn handle_git_prompt_push(
prompt: String,
askpass: Option<Option<StackId>>,
) -> Option<String> {
if let Some(branch_id) = askpass {
tracing::info!("received prompt for branch push {branch_id:?}: {prompt:?}");
askpass::get_broker()
.expect("askpass broker must be initialized")
.submit_prompt(prompt, askpass::Context::Push { branch_id })
.await
} else {
tracing::warn!("received askpass push prompt but no broker was supplied; returning None");
None
}
}View on GitHub (pinned to 58e5313667)