WSL: Release file for repository is not valid yet

Please use the following bug reporting template to help produce issues which are actionable and reproducible, including all command-line steps necessary to induce the failure condition. Please fill out all the fields! Issues with missing or incomplete issue templates will be closed.

If you have a feature request, please post to the UserVoice.

If this is a console issue (a problem with layout, rendering, colors, etc.), please post to the console issue tracker.

Important: Do not open GitHub issues for Windows crashes (BSODs) or security issues. Please direct all Windows crashes and security issues to secure@microsoft.com. Ideally, please configure your machine to capture minidumps, repro the issue, and send the minidump from "C:\Windows\minidump".

Please fill out the below information:

  • Your Windows build number: Microsoft Windows [Version 10.0.18917.1000]

  • What you’re doing and what’s happening: Attempting to run a sudo apt update within a WSL 2 installation. Seeing thing following error

[sudo] password for xander: Hit:1 https://packages.microsoft.com/repos/azure-cli bionic InRelease Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Hit:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Reading package lists… Done E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease is not valid yet (invalid for another 10h 29min 48s). Updates for this repository will not be applied. E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet (invalid for another 11h 0min 22s). Updates for this repository will not be applied.

Based on my own searching, I suspect the WSL clock may be falling out of sync with my windows machine? Though trying to cat /etc/localtime causes WSL to hang

  • What’s wrong / what should be happening instead: apt should run an update with no error output

  • Strace of the failing command, if applicable: (If some_command is failing, then run strace -o some_command.strace -f some_command some_args, and link the contents of some_command.strace in a gist here).

  • For WSL launch issues, please collect detailed logs.

See our contributing instructions for assistance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 25
  • Comments: 39 (5 by maintainers)

Commits related to this issue

Most upvoted comments

You could also try sudo hwclock -s, which does not need a restart of the underlying VM.

This seems to have to do with clock drift. If you shut down wsl and restart, is the problem solved?

wsl.exe --shutdown

apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update

will work around it temporarily.

This bug has given me HUGE frustration.

I’m coming off of two days of hunting a bug. I was trying to interact with Google BigQuery from code running inside a docker container. And I couldn’t for the life of me find out why on earth I can’t authenticate. For the longest time I thought the problem was introduced during the latest library update.

But how the hell am I supposed to think of the possibility that the problem is in fact that during authentication you need a correct clock otherwise during the request of a token you get an error response because a fucked up timer fucks up the expiry mechanism. Two days of my working life gone! Oh the hours I have spent trying to debug the library. fml.

How is this stupid bug not fixed a whole year later? I’m sorry for the language, but this has just been so frustrating. This issue is tagged “workaround available”. Screw that! That is so ironic. Just because the apt update command immediately complains and you can easily fix it by restarting WSL, doesn’t mean this bug isn’t a PITA in times when it’s completely unobvious that weird behavior is unrelated to the system clock.

Another quick fix:

sudo apt-get install ntpdate
sudo ntpdate pool.ntp.org

Working on WSL2, Ubuntu 20.04 LTS.

I used to have this problem with Docker for Windows. Whenever the machine hibernated, when it came back I had to go to Hyper-v Manager and disable and reenable Time sync, than it would be back to regular time. I’m pretty sure this is the same problem, it is happening to me in exactly the same pattern: whenever the computer hibernates. I’m on WSL 2. I can confirm that sudo hwclock -s fixes it, but this should come in the box. This did not happen before when this wsl instance was on WSL 1.

Confirmed that on Win 10 WSL 2 I had to use the following after hibernation:

 wsl -d docker-desktop hwclock -s

Cheers Manu

Hi all, I created a script that creates a scheduled task to automatically update the time of WSL when you either restore from sleep or you restore a “Saved” Hyper-V VM.

wsl -d Ubuntu -u root apt-get update && apt-get install ntpdate
schtasks /Create /TN wsl-clock /TR "wsl -d Ubuntu -u root ntpdate pool.ntp.org" /SC ONEVENT /EC System /MO "*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and (EventID=107 or EventID=507) or Provider[@Name='Microsoft-Windows-Kernel-General'] and (EventID=1)]]" /F

Change Ubuntu (in both places in the script) to the name of your WSL Instance (See wsl --list), then execute the script in cmd.

Thanks to all the other comments/suggestions that helped me create this script 😄 .

None of the above worked for me, but putting this in my WSL .bashrc is working so far (you have to apt install ntpdate). I run it in the background because it takes 7-10 seconds to run. hth

sudo ntpdate ntp.ubuntu.com &

Guys, please, help! HOW TO FIX THIS ***********N BUG??? None of recipes above work! 😦 Cannot proceed with my task as I am permanently stopped by this.

Moreover, I am thinking of returning to WSL1 if that will be possible.

OS: Windows 2004 (build 19041.329) Pro.

I used the workaround suggested by @leon-strong:

apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update

Another quick fix:

sudo apt-get install ntpdate
sudo ntpdate pool.ntp.org

Working on WSL2, Ubuntu 20.04 LTS.

Even better, added to ~/.bashrc 😃

This lost me hours of work last night as I tried to troubleshoot a mysterious auth error from Terraform as it was trying to deploy an Azure Storage Account. Shows up in the form of a “bad authorization header” error message.

https://github.com/stuartleeks/wsl-clock is quite a clever work around.

Guys, please, help! HOW TO FIX THIS ***********N BUG??? None of recipes above work! 😦 Cannot proceed with my task as I am permanently stopped by this. Moreover, I am thinking of returning to WSL1 if that will be possible. OS: Windows 2004 (build 19041.329) Pro.

I used the workaround suggested by @leon-strong:

apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update

That did not help, however, I was by some strange reason able to run a single-layer ‘apt-get’ command within my dockerfile - so that was pretty enough for me. I have been using all suggestions in a single line for it to work: apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false -o Acquire::Max-FutureTime=86400 update

Anyway, thanks for trying to help!

The big problem with wsl --shutdown is that it also affects Docker if that is installed.

Running into this same issue when running sudo apt update && sudo apt upgrade (Ubuntu 18.04 with WSL2 on windows insider build 18917.1000 on Macbook air).

Definitely some clock drift issue as the date command is returning the wrong time.

Shutting down WSL2 (wsl --shutdown) and rerunning the apt update command seems to fix it for now.

Laptop? Did it sleep? Maybe related this. WAG.