Adventures in programming: WSL and time drift

I went to try to install golang on my WSL install today, but my packages lists for apt-get were apparently out of date, so I got an error:

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-52.57_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Theoretically, this should be easy to solve with apt-get update, as recommended right there in the error message, but I got an error there too:

$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Reading package lists... Done
E: Release file for http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease is not valid yet (invalid for another 22h 43min 18s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 22h 43min 31s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease is not valid yet (invalid for another 22h 43min 55s). Updates for this repository will not be applied.

According to https://askubuntu.com/questions/1096930/sudo-apt-update-error-release-file-is-not-yet-valid, this happens if your clock is incorrect. My laptop clock looked OK, but the clock inside WSL was ~11 minutes behind. It turns out this is a known issue that the clock in WSL can get out of sync with the actual time clock: https://github.com/microsoft/WSL2-Linux-Kernel/issues/16 Luckily, the fix was quite simple:

$ date
Fri Jan  1 15:15:58 PST 2021
$ sudo hwclock --hctosys
$ date
Sat Jan  2 15:26:40 PST 2021

Running sudo hwclock --hctosys told WSL to sync its clock with the underlying hardware clock. Since that clock was already correct in my case, my problem was fixed and I was able to run apt-get update successfully, then install golang. And now that I’m documenting the solution for myself, it should be faster to figure out what’s going on next time!

Adventures in programming: Why is vim doing that?

Often in programming, you set out to write some code and you end up on a wild tangent instead. Seeing how someone else walks through one of their wild tangents can be very helpful, so here’s a walk through of the wild tangent I went on today.

What was I trying to do?


I’m working on scanning a bunch of old family photos and I eventually plan to put them online. Before I do so, I want to make sure the EXIF metadata is useful and well formatted, so I created myself a new github repo to store some scripts I’m planning to write. As I was writing a commit message while adding my initial .gitignore, I noticed that vim was inserting newlines and wrapping my commit message without me hitting Enter to move to a new line. While I certainly love a well formatted commit message, it really pulls me out of any kind of flow to have my text editor moving me to a new line without my asking. This annoys me enough, that I decided to dig into vim and figure out why my text was auto wrapping.

Why is vim automatically wrapping text?


Continue reading “Adventures in programming: Why is vim doing that?”