tzupdate icon indicating copy to clipboard operation
tzupdate copied to clipboard

Error: No such file or directory (os error 2)

Open doronbehar opened this issue 1 year ago • 4 comments

Hello,

Just tried to use your package on NixOS, and encountered the peculiar error in the title, when running with sudo and with --zoneinfo-path /etc/zoneinfo. Any idea why is that? How can I debug this myself? If I use also --print-only I get a valid result...

I checked that I can sudo touch /etc/timezone without an os error...

doronbehar avatar Sep 17 '24 06:09 doronbehar

I am not entirely familiar with Nix internals, but does it run under a mount namespace? If so you'll likely have to provide that at runtime.

cdown avatar Oct 01 '24 05:10 cdown

does it run under a mount namespace?

No, but perhaps I should mention that the /etc/timezone file doesn't exist by default in NixOS.

If so you'll likely have to provide that at runtime.

What do you mean by that?

doronbehar avatar Oct 01 '24 07:10 doronbehar

It shouldn't be a problem that it doesn't exist, then. What other restrictions are there? If you nsenter into a shell with the same context, can you touch there?

cdown avatar Oct 03 '24 06:10 cdown

It shouldn't be a problem that it doesn't exist, then. What other restrictions are there? If you nsenter into a shell with the same context, can you touch there?

Hmm I'm not sure how to test that... Indeed from some reason the same command works for me now when I'm using sudo on a normal terminal, so I cannot reproduce the original error. I'm pretty sure though, that before I ran sudo timedatectl set-timezone $(tzupdate --print-only) it didn't work... (reference: https://github.com/doronbehar/nixpkgs/commit/8efaf0d2d6ae01cdafe9de714ab803d9eaec2aca )

Feel free to close this if you really like to keep your bug tracker clean.

doronbehar avatar Oct 05 '24 19:10 doronbehar

For now I will close, since there's no repro, but feel free to reopen if reproducible. Thanks!

cdown avatar Nov 10 '24 22:11 cdown

i have the same issue - here are some additional details:

aaron@framework ~/framework> sudo RUST_LOG=tzupdate=trace /nix/store/g4f1qcjh9qwqvdjb7djzxk86sdvr5igl-tzupdate-3.1.0/bin/tzupdate -z /etc/zoneinfo
[2025-06-15T12:21:47Z DEBUG tzupdate::http] Sending America/Toronto back to main thread from https://ipapi.co//json/
[2025-06-15T12:21:47Z INFO  tzupdate] Got timezone America/Toronto
[2025-06-15T12:21:47Z DEBUG tzupdate::file] Symlinking /etc/.tmpdJbvGS to /etc/zoneinfo/America/Toronto
Error: No such file or directory (os error 2)

and then interestingly enough...

aaron@framework ~/framework [1]> ls -al /etc/.tmp*
lrwxrwxrwx 1 root root 29 Jun 15 12:21 /etc/.tmpdJbvGS -> /etc/zoneinfo/America/Toronto

no special permissions on /etc or anything weird like that, no sandboxing of any sort, etc... just running on my laptop

cc @cdown

aanderse avatar Jun 15 '25 12:06 aanderse

It will be from missing /etc/localtime. Are you using another method to manage time?

cdown avatar Jun 15 '25 14:06 cdown

i entirely removed /etc/localtime before running tzupdate - what should i be doing?

aanderse avatar Jun 15 '25 15:06 aanderse

Any particular reason you removed it? Applications rely on the link being present.

tzupdate is quite careful to do an atomic update for this reason, too. We can certainly handle it better, though.

cdown avatar Jun 15 '25 17:06 cdown

i specifically removed it before running tzupdate because thought i was supposed to remove it before running this 😅

so just run tzupdate without doing anything special first?

aanderse avatar Jun 15 '25 17:06 aanderse

Was there some documentation that misled you? If so we should update it. We are pretty careful about making sure it doesn't disappear. You don't need to remove anything before running tzupdate.

8a99c33d7d25c246b86078e7749bd377db540c19 will handle the case that it's missing without exiting, anyway.

cdown avatar Jun 15 '25 17:06 cdown

Was there some documentation that misled you?

i looked at the nixos module and probably went wrong there... i think you're good 👍

8a99c33 will handle the case that it's missing without exiting, anyway.

great, thanks for the help, all cleared up here 🙇‍♂

aanderse avatar Jun 15 '25 21:06 aanderse