tauri-apps/tauri · error

system clock is incorrect

Error message

system clock is incorrect

What it means

The tauri signer embeds a unix timestamp in updater signature keypairs/comments. unix_timestamp() computes SystemTime::now().duration_since(UNIX_EPOCH) and this expect panics when the duration is negative, i.e. the system clock currently reads a time before 1970-01-01 UTC. It is a pure environment problem, not a signing-key problem.

Source

Thrown at crates/tauri-cli/src/helpers/updater_signature.rs:191

  Ok(sk)
}

/// Gets the updater secret key from the given private key and password.
pub fn pub_key<S: AsRef<[u8]>>(public_key: S) -> crate::Result<PublicKey> {
  let decoded_publick = decode_key(public_key).context("failed to decode base64 pubkey")?;
  let pk_box =
    PublicKeyBox::from_string(&decoded_publick).context("failed to load updater pubkey")?;
  let pk = pk_box
    .into_public_key()
    .context("failed to convert updater pubkey")?;
  Ok(pk)
}

fn unix_timestamp() -> u64 {
  let start = SystemTime::now();
  let since_the_epoch = start
    .duration_since(UNIX_EPOCH)
    .expect("system clock is incorrect");
  since_the_epoch.as_secs()
}

fn open_data_file<P>(data_path: P) -> crate::Result<BufReader<File>>
where
  P: AsRef<Path>,
{
  let data_path = data_path.as_ref();
  let file = OpenOptions::new()
    .read(true)
    .open(data_path)
    .fs_context("failed to open data file", data_path.to_path_buf())?;
  Ok(BufReader::new(file))
}

#[cfg(test)]
mod tests {
  use super::*;

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Check the clock: run `date` and compare with real time.
  2. Enable NTP synchronization: `sudo timedatectl set-ntp true` (or enable systemd-timesyncd/chrony) and verify with `timedatectl`.
  3. For VMs/containers, enable host time sync (or set the correct time manually) and re-run the signer command.
  4. On hardware with a dead CMOS battery, replace the battery so the clock survives reboots.

Example fix

# before: clock before 1970 -> `tauri signer sign` panics
$ date
Thu Jan  1 00:12:34 UTC 1970

# after: sync and retry
$ sudo timedatectl set-ntp true
$ date && tauri signer sign -k ~/.tauri/myapp.key
Defensive patterns

Strategy: validation

Validate before calling

// Rust: precheck before invoking signer flows
use std::time::{SystemTime, UNIX_EPOCH};

if SystemTime::now().duration_since(UNIX_EPOCH).is_err() {
    eprintln!("system clock is before the Unix epoch; enable NTP and retry");
    std::process::exit(1);
}

Prevention

When it happens

Trigger: Running `tauri signer generate` or `tauri signer sign` on a machine whose clock is set before the Unix epoch: dead CMOS battery resetting the RTC, a VM or container started without time synchronization, or a manually mis-set clock.

Common situations: Old headless servers / Raspberry Pi class hardware with failed RTC batteries; CI containers with broken time injection; freshly cloned VMs before guest additions sync time.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/a41251faefa5e3ce. Report an issue: GitHub.