Staying organized is always a good idea. Not only does it apply to your physical space, but also to your digital one.

Since I tried Linux, I’ve been getting familiar with the concept of package managers. If you are not familiar with the term, a package manager is a tool that helps you install, update, configure, and remove software from your system. It’s like an app store for your computer.

In the case of macOS, the most popular package manager is Homebrew. It’s a free and open-source software that simplifies the installation of software on macOS.

Problem: Error: Could not cleanup old kegs! Fix your permissions on:

This error occurs when you don’t have the right permissions to delete the old kegs. And Homebrew will not allow us to execute the command along with sudo due to security reasons.

==> This operation has freed approximately 3GB of disk space.
Error: Could not cleanup old kegs! Fix your permissions on:
  /opt/homebrew/Cellar/python@3.12/3.12.6
 
 sudo brew cleanup --prune=all
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
 
 sudo chown -R "$USER":admin /opt/homebrew/Cellar/python@3.12/3.12.6
 
 brew cleanup --prune=all
Removing: /opt/homebrew/Cellar/python@3.12/3.12.6... (819 files, 10.5MB)
==> This operation has freed approximately 10.5MB of disk space.