Fix Music on Console (moc) on Arch Linux

The Problem

In this quick article I’ll go over the process to fix moc (Music on Console) not starting properly on Arch Linux.

Firstly, at the time of writing this article the current <a href="" target="_blank" rel="noreferrer noopener">moc</a> version is moc-1:2.5.2-5. Future releases may fix the issue described below.

Usually, installing moc on Arch Linux should be a simple case of running the following command:

sudo pacman -S moc

And, in fact, installing moc with pacman will appear to succeed without any issues:

Installing moc using Pacman … looks good, right?

Unfortunately, when you now try to run mocp, the following exception is immediately thrown:

Immediate exception when running mocp for the first time

… what the hell?

The Fix

Due to a bug in glibc 2.35, a patch needs to be applied to the moc package build files, after which the package can be rebuilt and the resulting binaries + docs + libs copied over those installed by pacman.

Because this is an Arch Linux article, I’ll assume you already have git installed. Let’s go.

  • Firstly, grab the moc package build files
git clone -b packages/moc --single-branch
  • Enter the main source directory and open the PKGBUILD file for editing (use any editor that suits you)
  • Modify the source array as follows, making sure to keep the quotes intact:
  • Modify the prepare() function as follows:
prepare() {
  cd $pkgname-$pkgver
  patch -p0 -i ../moc-ffmpeg4.patch # Fix build with ffmpeg 4
  patch -p0 -i ../moc-https.patch  # Allow https for urls
  patch -p0 -i ../glibc-2.35.patch # FS74041
  • Save the PKGBUILD file and close the editor
  • Build the package, making sure to tell the process to skip integrity checks.
makepkg --skipinteg

The man page for the makepkg --skipinteg parameter is as follows:

Do not perform any integrity checks (checksum and PGP) on source files.

makepkg man page, –skipinteg parameter info

When an error occurs indicating the current file being patched can’t be found, it’s a simple case of entering utf8.c and pressing enter:

patching file files.c
can't find file to patch at input line 32
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
File to patch: utf8.c

If the build process is successful, the output will end something like this:

makepkg --skipinteg completed, including entering utf8.c when prompted

Updating moc Installation

A successful build will result in a new moc package in the pkg directory. The contents of the package’s root directory are nothing more than a usr directory, as follows:

Contents of new moc package

The last step is to copy those files into place, overwriting existing files. This assumes you’ve already changed to the pkg/moc directory.

cd usr
sudo cp -R * /usr

By default there’s no output after copying these files:

Copying newly built moc files into place

Test moc

So now there’s only one thing left to do … run mocp!

mocp running after being patched and rebuilt


Thanks to the participants in the Arch Linux bug tracker for this info. Given the time I spent finding a process that actually worked (poor Google fu, maybe), I’m keeping a record of it here so I can refer back later, if required.

Hope it helps someone.