Skip to content

no field st_mtimensec on type rustix::fs::Stat #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0323pin opened this issue May 9, 2025 · 2 comments · Fixed by #2005
Closed

no field st_mtimensec on type rustix::fs::Stat #2004

0323pin opened this issue May 9, 2025 · 2 comments · Fixed by #2005

Comments

@0323pin
Copy link

0323pin commented May 9, 2025

Hi,

This has started to happen recently,

   Compiling gix-index v0.40.0
error[E0609]: no field `st_mtimensec` on type `rustix::fs::Stat`
  --> /tmp/shells/starship/work/vendor/gix-index-0.40.0/src/fs.rs:65:38
   |
65 |             let nanoseconds = self.0.st_mtimensec;
   |                                      ^^^^^^^^^^^^ unknown field
   |
help: a field with a similar name exists
   |
65 |             let nanoseconds = self.0.st_mtime_nsec;
   |                                      ~~~~~~~~~~~~~

error[E0609]: no field `st_ctimensec` on type `rustix::fs::Stat`
  --> /tmp/shells/starship/work/vendor/gix-index-0.40.0/src/fs.rs:94:38
   |
94 |             let nanoseconds = self.0.st_ctimensec;
   |                                      ^^^^^^^^^^^^ unknown field
   |
help: a field with a similar name exists
   |
94 |             let nanoseconds = self.0.st_ctime_nsec;
   |                                      ~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0609`.
error: could not compile `gix-index` (lib) due to 2 previous errors
*** Error code 101

See for example, http://www.ki.nu/pkgsrc/reports/current/NetBSD-9.0/20250505.0626/starship-1.23.0/build.log or, http://www.ki.nu/pkgsrc/reports/current/NetBSD-9.0/20250505.0626/mise-2025.5.0/build.log

This seems to be related to #1170

But, I don't know exactly what has changed recently.

Any help would be appreciated, thank you.

@0-wiz-0
Copy link
Contributor

0-wiz-0 commented May 9, 2025

I found this in the rustix::fs CHANGES file:

On NetBSD, the nanoseconds fields of [`Stat`] have been renamed, for consistency
with other platforms:

so the NetBSD special case can be removed:

diff --git i/gix-index/src/fs.rs w/gix-index/src/fs.rs
index 5fb369f9e..2be45bb8d 100644
--- i/gix-index/src/fs.rs
+++ w/gix-index/src/fs.rs
@@ -59,10 +59,8 @@ impl Metadata {
             #[cfg(any(target_os = "aix", target_os = "hurd"))]
             let seconds = self.0.st_mtim.tv_sec;

-            #[cfg(not(any(target_os = "netbsd", target_os = "aix", target_os = "hurd")))]
+            #[cfg(not(any(target_os = "aix", target_os = "hurd")))]
             let nanoseconds = self.0.st_mtime_nsec;
-            #[cfg(target_os = "netbsd")]
-            let nanoseconds = self.0.st_mtimensec;
             #[cfg(any(target_os = "aix", target_os = "hurd"))]
             let nanoseconds = self.0.st_mtim.tv_nsec;

@@ -88,10 +86,8 @@ impl Metadata {
             #[cfg(any(target_os = "aix", target_os = "hurd"))]
             let seconds = self.0.st_ctim.tv_sec;

-            #[cfg(not(any(target_os = "netbsd", target_os = "aix", target_os = "hurd")))]
+            #[cfg(not(any(target_os = "aix", target_os = "hurd")))]
             let nanoseconds = self.0.st_ctime_nsec;
-            #[cfg(target_os = "netbsd")]
-            let nanoseconds = self.0.st_ctimensec;
             #[cfg(any(target_os = "aix", target_os = "hurd"))]
             let nanoseconds = self.0.st_ctim.tv_nsec;

@EliahKagan
Copy link
Member

Thanks! I missed the need for such a change when reviewing and merging #1949. The upgrade of rustix to 1.* came in at 68e6b2e. I've reproduced this gix-index bug on NetBSD 10.1 amd64 by installing the gitoxide crate from crates.io, as well as by running cargo build. Here's a log showing the latter. The patch in #2005 fixes the problem, allowing the build to succeed, as this other log shows.

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 a pull request may close this issue.

3 participants