'Cannot install bazel on Ubuntu 20.04 - invalid EXPKEYSIG

I was following the instructions on https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu

and trying to install bazel on Ubuntu.

When I run step 2: sudo apt update && sudo apt install bazel

I get:

Get:1 https://storage.googleapis.com/bazel-apt stable InRelease [2,256 B]
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease                                                         
Hit:3 http://us.archive.ubuntu.com/ubuntu focal InRelease                            
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease                    
Err:1 https://storage.googleapis.com/bazel-apt stable InRelease
  The following signatures were invalid: EXPKEYSIG 3D5919B448457EE0 Bazel Developer (Bazel APT repository key) <[email protected]>
Hit:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease                  
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease                     
Reading package lists... Done
W: GPG error: https://storage.googleapis.com/bazel-apt stable InRelease: The following signatures were invalid: EXPKEYSIG 3D5919B448457EE0 Bazel Developer (Bazel APT repository key) <[email protected]>
E: The repository 'https://storage.googleapis.com/bazel-apt stable InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Anyone know how to fix this?



Solution 1:[1]

The Bazel Ubuntu PPA key has expired.

From https://github.com/bazelbuild/bazel/issues/11470#issuecomment-633205152:

You may have to manually update your apt keyring with the new key:

$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get update

Solution 2:[2]

Try to install Bazel by using Bazelisk as follows:

  1. cd ~
  2. wget https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64
  3. chmod +x bazelisk-linux-amd64
  4. sudo ln -s ~/bazelisk-linux-amd64 /usr/bin/bazel
  5. to test run: bazel version

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Idan Petel