[Solved] Error: No such keg: /usr/local/Cellar/gcc

devharsh@Devharshs-MacBook-Pro ~ % brew update && brew upgrade && brew cleanup
Already up-to-date.
Warning: Skipping gcc: most recent version 12.1.0 not installed
devharsh@Devharshs-MacBook-Pro ~ % brew install -f gcc@12
Error: gcc 12.1.0_1 is already installed
To install 12.1.0, first run:
brew unlink gcc
devharsh@Devharshs-MacBook-Pro ~ % brew unlink gcc
Error: No such keg: /usr/local/Cellar/gcc
devharsh@Devharshs-MacBook-Pro ~ % brew unlink gcc@12
Unlinking /usr/local/Cellar/gcc@12/12.1.0_1... 665 symlinks removed.
This worked successfully, after which I did a reinstallation.
devharsh@Devharshs-MacBook-Pro ~ % brew install -f gcc
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/manifests/12.1.0
Already downloaded: /Users/devharsh/Library/Caches/Homebrew/downloads/30be1d1b4338e63c6393a6c65a6baaa374b8ad16b0d72df58bcda25fa0b72cd4--gcc-12.1.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/blobs/sha256:ef8d827aef3df5e5017f019c2d0ae5e3371306305ff2b74c7a1c218ca72a7ab6
Already downloaded: /Users/devharsh/Library/Caches/Homebrew/downloads/45d3f50e0ee23935e38f181b78ea620c00da2d7a4169d5a50f906f3821b3396d--gcc--12.1.0.monterey.bottle.tar.gz
==> Pouring gcc--12.1.0.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/gcc/12.1.0: 1,566 files, 299.6MB
==> Running `brew cleanup gcc`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
So far, I could successfully unlinked and installed the latest GCC version. Then I did a homebrew update to check if I got rid of the warning, and it worked! 🥳
devharsh@Devharshs-MacBook-Pro ~ % brew update && brew upgrade && brew cleanup
Already up-to-date.
/usr/bin/ruby
Execute the following command, and change the ruby path if it is different for your system.
devharsh@Devharshs-MacBook-Pro ~ % /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Warning: The Ruby Homebrew uninstaller is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
/Users/devharsh/Library/Caches/Homebrew/
/Users/devharsh/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] N
This Homebrew error, No such keg for the GCC package, appears when a formula's files are missing or unlinked, often after an interrupted update, so Homebrew cannot find the version it expects.
Relinking or reinstalling the affected formula generally repairs it, after which brew update and upgrade complete normally. Keeping Homebrew current avoids many of these mid update glitches.

Comments
Post a Comment