homebrew install Error

Problem

An error “Permission denied @ apply2files – /usr/local/share/ghostscript/9.23/Resource/CIDFSubst/Deng.ttf” occurred when I tried to update homebrew.

What is homebrew?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)

What is ghostscript?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)
Ghostscript is invoked and started by other software including homebrew.

The Resource / CIDFSubst directory is a directory to store TrueType fonts (but there is no problem here).

Cause of the error

Because the error message says “Permission denied”, the current user does not have access. So it seems that homebrew cannot use the required files.

Solution

As an immediate solution, give access to the ghostscript directory with the following command. You will be prompted for a password.

sudo chown -R <UserName>:admin /usr/local/share/ghostscript

Now you can run without error. It remains unclear why the access was lost.