lsd-rs/lsd · error

failed to retrieve modified date

Error message

failed to retrieve modified date

What it means

Date::from(&Metadata) calls Metadata::modified() and .expect()s it to succeed. On platforms/filesystems where the modification time is unavailable (std returns io::Error), this panic aborts eza instead of rendering the date column. The library assumes mtime always exists, which is not guaranteed on exotic filesystems.

Solutions

  1. Identify the file triggering it and check its filesystem (stat <file>); copy/move the file to a filesystem that supports mtime.
  2. If you build eza, replace the expect with graceful degradation: use meta.modified().ok().map(Into::into).unwrap_or_default() and render a placeholder.
  3. Update/upgrade the FUSE or network filesystem driver so it reports timestamps.
  4. Work around by excluding the offending mount from the listing (e.g. list a different directory, adjust ignore globs).

Example fix

// before
meta.modified().expect("failed to retrieve modified date").into()
// after
match meta.modified() {
    Ok(mtime) => mtime.into(),
    Err(_) => SystemTime::UNIX_EPOCH.into(), // or skip the date column
}
Defensive patterns

Strategy: try-catch

Validate before calling

match std::fs::metadata(path) {
    Ok(meta) => match meta.modified() {
        Ok(_) => { /* safe to list */ },
        Err(e) => eprintln!("no mtime for {}: {}", path.display(), e),
    },
    Err(e) => eprintln!("stat failed: {}", e),
}

Type guard

fn has_mtime(meta: &std::fs::Metadata) -> bool {
    meta.modified().is_ok()
}

Try / catch

let date = std::panic::catch_unwind(|| Date::from(&meta))
    .unwrap_or_else(|_| Date::from(std::time::SystemTime::UNIX_EPOCH));
// or, if patching the library: meta.modified().ok().map(Into::into).unwrap_or_default()

Prevention

When it happens

Trigger: Listing files whose filesystem cannot supply a modified time — Metadata::modified() returns Err — while eza renders metadata (from() invoked during date column rendering).

Common situations: Files on network filesystems (NFS/SMB), FUSE mounts, some procfs/sysfs virtual files, or Windows FAT volumes with missing timestamps; files created/modified by the OS in ways that leave mtime unset.

Related errors


AI-assisted analysis of lsd-rs/lsd@4b6c14a110 (2026-09-04). Data as JSON: /api/errors/3d65ebe71d800ff7. Report an issue: GitHub.

Appendix: source

Thrown at src/meta/date.rs:29

pub enum Date {
    Date(DateTime<Local>),
    Invalid,
}

// Note that this is split from the From for Metadata so we can test this one (as we can't mock Metadata)
impl From<SystemTime> for Date {
    fn from(systime: SystemTime) -> Self {
        // FIXME: This should really involve a result, but there's upstream issues in chrono. See https://github.com/chronotope/chrono/issues/110
        let res = panic::catch_unwind(|| systime.into());

        res.map_or(Date::Invalid, Date::Date)
    }
}

impl From<&Metadata> for Date {
    fn from(meta: &Metadata) -> Self {
        meta.modified()
            .expect("failed to retrieve modified date")
            .into()
    }
}

impl Date {
    pub fn render(&self, colors: &Colors, flags: &Flags) -> ColoredString {
        let date_string = self.date_string(flags);
        let elem = match self {
            Self::Date(modified) => Elem::Date(modified.timestamp()),
            Self::Invalid => Elem::InvalidDate,
        };

        colors.colorize(date_string, &elem)
    }
    fn date_string(&self, flags: &Flags) -> String {
        let locale = current_locale();

        if let Date::Date(val) = self {

View on GitHub (pinned to 4b6c14a110)