Recently, I went back from using Visual Studio Code almost exclusively to using Sublime Text for most of my editing work. I’m a paying customer (And have been using the most excellent Sublime Merge as my git GUI of choice all the way through, as I found the VS Code git integration a bit lacking). Also I have to set up this new machine (More on that in another blog post) and so I am going through all of the tools I need and figuring out how to best install them on this machine.

For years now the official instructions on how to install Sublime Text and Sublime Merge are somewhat wrong. The reason is that Ubuntu (And, I believe, Debian as well) have changed the way the GPG keys are supposed to be stored and referenced for third party repositories. I am still not 100% sure why this change, that actually makes installing software from third party repositories so much harder, was neccessary, but there are probably good security reasons for it.

In any case, by taking inspiration from the official Docker instructions I was able to cobble together the instructions to do this in the “official” way on modern Ubuntu.

I thought it would be useful to have a version available that explains this line by line and thus make it applicable to other cases.

Let’s start with setting up the necessary tools (it’s very likely you have these packages installed, but better be safe than sorry):

sudo apt-get update
sudo apt-get install ca-certificates curl

Next, we’re using the install command as a slightly nicer version of mkdir -p to create a keyrings directory that will hold our gpg key

sudo install -m 0755 -d /etc/apt/keyrings

Next, let’s actually download the key and make it generally available

sudo curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg -o /etc/apt/keyrings/sublime.asc
sudo chmod a+r /etc/apt/keyrings/sublime.asc

Quick note: SublimeHQ does not provide instructions on how to validate the GPG key. But if you’re well versed with gpg, you should be able to figure that out.

Next comes the interesting part: The actual apt source configuration, which will contain the path to the keyring file, so that apt knows how to validate the sources.

echo \                                     
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/sublime.asc] https://download.sublimetext.com/ apt/stable/" | \
  sudo tee /etc/apt/sources.list.d/sublime-hq.list > /dev/null

After that, we can just update apt and install the packages:

sudo apt update

sudo apt install sublime-text sublime-merge

I’ll try to make SublimeHQ update their instructions but I am not very helpful that this will happen quickly.