Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Node.js 20 on Ubuntu22 Installation fail #1780

Closed
carefreepineapple opened this issue Mar 1, 2024 · 5 comments
Closed

[ERROR] Node.js 20 on Ubuntu22 Installation fail #1780

carefreepineapple opened this issue Mar 1, 2024 · 5 comments
Assignees
Labels

Comments

@carefreepineapple
Copy link

carefreepineapple commented Mar 1, 2024

Describe your bug
Cant install nodejs 20 on ubuntu 22 (nodejs 18 fails as well)

Err:1 https://deb.nodesource.com/node_20.x nodistro InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4

Distribution Information:

~$ cat /etc/os-release | grep VERSION=
VERSION="22.04.4 LTS (Jammy Jellyfish)"

Node Version:

  • Node: Node.js 20.x
  • Node: Node.js 18.x

To Reproduce
Steps to reproduce the behavior:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

Expected behavior
Node.js 20.x to be installed.

Additional context
Nodejs.18x was originally installed.

Steps done to remove nodejs.x thus far

~$ sudo rm /etc/apt/sources.list.d/nodesource.list
~$ sudo rm /usr/share/keyrings/nodesource.gpg
~$ sudo rm /etc/apt/keyrings/nodesource.gpg
~$ sudo apt purge libnode72 node-*
~$ sudo apt remove nodejs libnode72 libnode-dev nodejs-doc
~$ sudo rm `sudo find / -name nodesource.gpg`
~$ sudo rm `sudo find / -name nodesource.key`
~$ sudo find /etc -name "*node*" -type f -delete
~$ sudo find /usr/bin -name 'node*' -exec rm -rf {} \;
~$ sudo find /usr/local/bin -name 'node*' -exec rm -rf {} \;
~$ sudo rm -rf ~/.npm ~/.node-gyp ~/.npmrc ~/.npm-init.js /usr/local/lib/node_modules
~$ sudo find /usr -name 'node*' -type d -exec rm -rf {} \;
~$ sudo find /usr/local -name 'node*' -type d -exec rm -rf {} \;
~$ sudo apt autoremove -y
~$ sudo apt --fix-broken install
~$ sudo apt-get clean
~$ sudo apt update -y
~$ sudo apt upgrade -y

Steps done to install nodejs and verification

~$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# verify source file contents, specifically the path for the gpg key 
~$ sudo cat /etc/apt/sources.list.d/nodesource.list
deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main

# make sure the gpg key has the correct permissions
~$ sudo chmod a+r /usr/share/keyrings/nodesource.gpg

# make sure the gpg key has the correct key
~$ sudo gpg --show-keys --with-subkey-fingerprint /usr/share/keyrings/nodesource.gpg
pub   rsa2048 2016-05-23 [SC]
      6F71F525282841EEDAF851B42F59B5F99B1BE0B4
uid                      NSolid <[email protected]>
sub   rsa2048 2016-05-23 [E]
      0FA5ECC8C0CA58863C0AC5867E9656125E955B26

# verify the hosted key has the same signature
~$ curl -fsSL --compressed   "https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key" | gpg --dry-run --show-keys -
gpg: keyblock resource '/home/ansible/.gnupg/pubring.kbx': No such file or directory
pub   rsa2048 2016-05-23 [SC]
      6F71F525282841EEDAF851B42F59B5F99B1BE0B4
uid                      NSolid <[email protected]>
sub   rsa2048 2016-05-23 [E]

# tried downloading the key manually, no change.
~$ sudo curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg

# tried making a symlink to /etc/apt/keyrings just in case, no change.
~$ ln -s /usr/share/keyrings/nodesource.gpg /etc/apt/keyrings/

# nodesource.gpg has all the same permissions as the other gpg files.
~$ sudo ls -la /usr/share/keyrings/nodesource.gpg
-rw-r--r-- 1 root root 1185 Mar  1 05:53 /usr/share/keyrings/nodesource.gpg
@carefreepineapple
Copy link
Author

carefreepineapple commented Mar 1, 2024

So the resolution to this was to instead create the gpg key within /etc/apt/trusted.gpg.d and NOT /usr/share/keyrings

So it should be:

~$ sudo curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/nodesource.gpg
~$ echo "deb [arch=$arch signed-by=/etc/apt/trusted.gpg.d/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list > /dev/null

This appears to be a result of the update to Ubuntu 22.04 where they transitioned from using /etc/apt/trusted.gpg to using individual .gpg files located in /etc/apt/trusted.gpg.d.

Created a Pull Request for this update.
#1781

@georgejdli
Copy link

I am seeing the same issue in 20.04

cat /etc/os-release | grep VERSION=
VERSION="20.04.6 LTS (Focal Fossa)"
Err:4 https://deb.nodesource.com/node_18.x nodistro InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4
Reading package lists... Done
W: GPG error: https://deb.nodesource.com/node_18.x nodistro InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4
E: The repository 'https://deb.nodesource.com/node_18.x nodistro InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.

@riosje riosje self-assigned this Mar 20, 2024
@riosje
Copy link
Contributor

riosje commented Mar 26, 2024

Hello guys, I'm not being able to replicate this issue.
I'm using the new installation scripts everything works perfectly out of the box.

docker run -it ubuntu:22.04 bash

apt-get update -y && apt-get install curl -y
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs

@georgejdli
Copy link

curl -fsSL https://deb.nodesource.com/setup_20.x | bash -

Yes it's working for me now too
I had to run this command first apt-get update -y && apt-get install curl -y to get it to work.

I'm guessing we needed to run apt-get update -y first? Should that be added to the README?

@riosje
Copy link
Contributor

riosje commented Mar 26, 2024

Hi @georgejdli, I'm glad is working now.

@riosje riosje closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants