Being Wrong and Happy For Four Month
Tags: apt, node, npm, story
Published: 2018-08-28 15:41:43

---
title: Being Wrong and Happy For Four Month
published: true
description: How I misunderstood a press-release style feature list and jumped to the wrong conclusions.
tags: apt, node, npm, story
---

Ugh.

Yesterday, I wanted to use node and npm to write something. This is something I rarely do. I wanted to use it on an old server running ubuntu. I ran node. It was there. I ran npm. It was no there. I checked the node binary and the deb package from which it came. It was from the ubuntu 18.04 repo. I could either apt install npm to get an old version of npm, or I could upgrade the node from the ubuntu repo to the nodesource repo which includes a newer npm. I chose the later.

This is where my enlightenment began.

Four months ago I was happy to see that the `apt update` command was no longer required after running add-apt-repository. When I read it on https://itsfoss.com/ubuntu-18-04-release-features/ I thought that '-u' was now the default behavior. That would be the most efficient way to implement this feature. I had jumped to conclusions.

Let me back up 3 years.

I was working on a cloud deployment tool which deployed many new ubuntu images and installed things on them. This meant a lot of apt-get update and add-apt-repository calls. It was slow. It was even slower when run on a cloud with slow internet and non-local repositories. All of those http roundtrips to remote servers to fetch the same results from apt-get update was driving me mad. I don't like slow things. There had to be a way to speed things up.

I wrote the '-u' feature to add-apt-repository, I submitted it, and it was accepted with thanks. I was very happy. I felt that I'd made the world a better place, even if only a tiny bit for some of us techie folks. The '-u' feature works by fetching and merging the new package information only for the newly added repository instead of for ALL repositories like apt-get update does. It can shave a minute or more from a deploy which adds repositories, couple that with a deploy which uses multiple machines or system containers and it multiplies.

Back to yesterday with npm.

I ran the add-apt-repository command without -u, because it shouldn't be needed, or so I thought...

```
sudo add-apt-repository 'deb https://deb.nodesource.com/node_8.x bionic main'
```

slow.

It was very slow.

It turns out my conclusion that -u was default is wrong. A full (usually needless) apt-get update is now the default. ugh. disappointment.

Conclusion: continue to use '-u' with add-apt-repository.

Footnote:

I use these commands to get nodejs on an ubuntu bionic system. The node_8.x can be changed to node_10.x for the 10.x repo. bionic can be any of stretch, jessie, buster, sid, trusty, xenial, precise. * I think some combinations may not work, but as long as you are on new enough distro, the newer node repos from nodesource will work.

```
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
sudo add-apt-repository -u 'deb https://deb.nodesource.com/node_8.x bionic main'
sudo apt purge npm # may not be required if it is not already installed.
sudo apt install nodejs
```