54

I just installed Ubuntu 22.04 LTS for Windows Subsystem for Linux, but I'm having some issues. Every time I install new packages using sudo apt install, I will get 2 messages saying that:

Failed to retrieve available kernel versions.
Failed to check for processor microcode upgrades.

This issue doesn't happen when using Ubuntu 20.04 LTS.

Even though I get these messages, I can install Linux packages and integrate them into Visual Studio Code successfully. And when I check the kernel using uname -r, I get 5.10.102.1-microsoft-standard-WSL2.

Everything works fine, but these messages keep concerning me.

I am wondering why these messages appear and how I can fix them. Can anyone give me some suggestions to fix these issues? Are these messages fatal?

enter image description here

NotTheDr01ds
  • 17,888
Liu Bei
  • 741

1 Answers1

81

Short answer:

sudo -e /etc/needrestart/needrestart.conf

Note: -e uses the default system editor. If you want to use a different editor, simply run sudo update-alternatives --config editor

Uncomment and change the following settings:

$nrconf{kernelhints} = 0;
$nrconf{ucodehints} = 0;

You will no longer get those warnings when installing packages.

More details:

This is similar in background to the same "problem" occurring on the Raspberry Pi, but with a somewhat different root cause.

There's really nothing to be concerned about. This is a (recently) new check done by Ubuntu after installing packages to determine if other actions need to be taken.

The package that handles this (and is causing those warnings) is needrestart. From apt show needstart:

Description: check which daemons need to be restarted after library upgrades
 needrestart checks which daemons need to be restarted after library upgrades.
 It is inspired by checkrestart from the debian-goodies package.

Features:

  • supports (but does not require) systemd
  • binary blacklisting (i.e. display managers)
  • tries to detect required restarts of interpreter based daemons (supports Java, Perl, Python, Ruby)
  • tries to detect required restarts of containers (docker, LXC)
  • tries to detect pending kernel upgrades
  • tries to detect pending microcode upgrades for Intel CPUs
  • could be used as nagios check_command
  • fully integrated into apt/dpkg using hooks

Neither the kernel nor microcode under will ever report correctly under WSL2, since we are running Ubuntu in a container inside the WSL2 VM (that we can't access). However, given the information above, there may be some scenarios in which it could come in handy, depending on what other daemons or containers you run.

You can continue to use the rest of the features without the kernel/microcode checks with the configuration file changes above. Whether or not they are useful will depend on your WSL2 use-cases.

Alternatively, you can, if you find that the extra output doesn't come in handy, remove the feature entirely (per the guidance in the Raspberry Pi question) via:

sudo apt-get purge needrestart

Personally, I'm not sure yet that this package really makes sense to have as a part of the default 22.04 rootfs for WSL2. But time will tell. I feel certain that a lot of people are going to have this question as they start to install 22.04 in WSL, though.

WSL1 Users

If, however, you are on WSL1, my recommendation at this stage of my investigation is to remove the package completely. The process that needrestart uses to check for obsolete packages does not seem to work under WSL1's syscall translation "pseudo-kernel", and you will receive regular false-positives from needrestart about running outdated binaries and libraries, including sh, apt, and init (among others).

NotTheDr01ds
  • 17,888